Fix key_press event not only on key down
This commit is contained in:
parent
7fb3525ec7
commit
7616f1e3f2
1 changed files with 5 additions and 2 deletions
|
@ -3,7 +3,7 @@ mod display;
|
||||||
mod mpd_handler;
|
mod mpd_handler;
|
||||||
|
|
||||||
use ggez::conf::{WindowMode, WindowSetup};
|
use ggez::conf::{WindowMode, WindowSetup};
|
||||||
use ggez::event::winit_event::{KeyboardInput, ModifiersState};
|
use ggez::event::winit_event::{ElementState, KeyboardInput, ModifiersState};
|
||||||
use ggez::event::{self, ControlFlow, EventHandler};
|
use ggez::event::{self, ControlFlow, EventHandler};
|
||||||
use ggez::graphics::{self, Rect};
|
use ggez::graphics::{self, Rect};
|
||||||
use ggez::{ContextBuilder, GameError};
|
use ggez::{ContextBuilder, GameError};
|
||||||
|
@ -79,6 +79,7 @@ fn main() -> Result<(), String> {
|
||||||
input:
|
input:
|
||||||
KeyboardInput {
|
KeyboardInput {
|
||||||
virtual_keycode: Some(keycode),
|
virtual_keycode: Some(keycode),
|
||||||
|
state,
|
||||||
..
|
..
|
||||||
},
|
},
|
||||||
is_synthetic: _,
|
is_synthetic: _,
|
||||||
|
@ -90,8 +91,10 @@ fn main() -> Result<(), String> {
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
if state == ElementState::Pressed {
|
||||||
display.key_down_event(ctx, keycode, modifiers_state.into(), false);
|
display.key_down_event(ctx, keycode, modifiers_state.into(), false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
event::winit_event::WindowEvent::Resized(phys_size) => {
|
event::winit_event::WindowEvent::Resized(phys_size) => {
|
||||||
graphics::set_screen_coordinates(
|
graphics::set_screen_coordinates(
|
||||||
ctx,
|
ctx,
|
||||||
|
|
Loading…
Reference in a new issue