From bcc951a8fcadd72af327022215baa287c2065951 Mon Sep 17 00:00:00 2001 From: Anish Jewalikar Date: Wed, 13 Oct 2021 11:38:19 +0530 Subject: [PATCH] Fix a bug in SDL 2 support crate (#549). --- imgui-sdl2-support/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/imgui-sdl2-support/src/lib.rs b/imgui-sdl2-support/src/lib.rs index 2c899bb..edf8c6b 100644 --- a/imgui-sdl2-support/src/lib.rs +++ b/imgui-sdl2-support/src/lib.rs @@ -29,7 +29,7 @@ use sdl2::{ /// macOS now...) #[derive(Debug, Clone, Copy, Default)] struct Button { - pressed_this_frame: bool, + pub pressed_this_frame: bool, state: bool, } @@ -249,7 +249,11 @@ impl SdlPlatform { // Update mouse button state for (io_down, button) in io.mouse_down.iter_mut().zip(&mut self.mouse_buttons) { *io_down = button.get(); - *button = Button::new(); + + // this frame is now "over" and we can set pressed_this_frame to false, but + // the state cannot be set to false due to actions that require multi-frame inputs + // ie: dragging, resizing and this is handled by the `MouseButtonDown` event. + button.pressed_this_frame = false; } // Set mouse position if requested by imgui-rs