Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sanbox-irl committed Feb 22, 2022
1 parent 24ad9d5 commit 9d90289
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions imgui-sdl2-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,25 +167,29 @@ impl SdlPlatform {
///
/// * keyboard state is updated
/// * mouse state is updated
pub fn handle_event(&mut self, context: &mut Context, event: &Event) {
pub fn handle_event(&mut self, context: &mut Context, event: &Event) -> bool {
let io = context.io_mut();

match *event {
Event::MouseWheel { x, y, .. } => {
io.mouse_wheel = y as f32;
io.mouse_wheel_h = x as f32;
true
}

Event::MouseButtonDown { mouse_btn, .. } => {
self.handle_mouse_button(&mouse_btn, true);
true
}

Event::MouseButtonUp { mouse_btn, .. } => {
self.handle_mouse_button(&mouse_btn, false);
true
}

Event::TextInput { ref text, .. } => {
text.chars().for_each(|c| io.add_input_character(c));
true
}

Event::KeyDown {
Expand All @@ -195,6 +199,7 @@ impl SdlPlatform {
} => {
io.keys_down[key as usize] = true;
handle_key_modifier(io, &keymod);
true
}

Event::KeyUp {
Expand All @@ -204,9 +209,10 @@ impl SdlPlatform {
} => {
io.keys_down[key as usize] = false;
handle_key_modifier(io, &keymod);
true
}

_ => {}
_ => false
}
}

Expand Down

0 comments on commit 9d90289

Please sign in to comment.