TAB toggles UI visibility in the demo

This commit is contained in:
Alan Jeffrey 2019-04-02 15:55:38 -05:00
parent 0166ff96de
commit dc77a5262f
3 changed files with 9 additions and 0 deletions

View File

@ -341,6 +341,13 @@ impl<W> DemoApp<W> where W: Window {
self.dirty = true;
}
}
Event::KeyDown(Keycode::Tab) => {
self.options.ui = match self.options.ui {
UIVisibility::None => UIVisibility::Stats,
UIVisibility::Stats => UIVisibility::All,
UIVisibility::All => UIVisibility::None,
}
}
Event::OpenSVG(ref svg_path) => {
let built_svg = load_scene(self.window.resource_loader(), svg_path);
self.ui.message = get_svg_building_message(&built_svg);

View File

@ -57,6 +57,7 @@ pub enum Event {
pub enum Keycode {
Alphanumeric(u8),
Escape,
Tab,
}
#[derive(Clone, Copy, Debug)]

View File

@ -227,6 +227,7 @@ impl WindowImpl {
fn convert_sdl_keycode(&self, sdl_keycode: SDLKeycode) -> Option<Keycode> {
match sdl_keycode {
SDLKeycode::Escape => Some(Keycode::Escape),
SDLKeycode::Tab => Some(Keycode::Tab),
sdl_keycode if sdl_keycode as i32 >= SDLKeycode::A as i32 &&
sdl_keycode as i32 <= SDLKeycode::Z as i32 => {
let offset = (sdl_keycode as i32 - SDLKeycode::A as i32) as u8;