diff --git a/src/ImGui.NET.SampleProgram/ImGuiController.cs b/src/ImGui.NET.SampleProgram/ImGuiController.cs index 467b4c4..363ee32 100644 --- a/src/ImGui.NET.SampleProgram/ImGuiController.cs +++ b/src/ImGui.NET.SampleProgram/ImGuiController.cs @@ -332,13 +332,34 @@ namespace ImGuiNET Vector2 mousePosition = snapshot.MousePosition; - io.MousePos = mousePosition; - io.MouseDown[0] = snapshot.IsMouseDown(MouseButton.Left); - io.MouseDown[1] = snapshot.IsMouseDown(MouseButton.Right); - io.MouseDown[2] = snapshot.IsMouseDown(MouseButton.Middle); + // Determine if any of the mouse buttons were pressed during this snapshot period, even if they are no longer held. + bool leftPressed = false; + bool middlePressed = false; + bool rightPressed = false; + foreach (MouseEvent me in snapshot.MouseEvents) + { + if (me.Down) + { + switch (me.MouseButton) + { + case MouseButton.Left: + leftPressed = true; + break; + case MouseButton.Middle: + middlePressed = true; + break; + case MouseButton.Right: + rightPressed = true; + break; + } + } + } - float delta = snapshot.WheelDelta; - io.MouseWheel = delta; + io.MouseDown[0] = leftPressed || snapshot.IsMouseDown(MouseButton.Left); + io.MouseDown[1] = middlePressed || snapshot.IsMouseDown(MouseButton.Right); + io.MouseDown[2] = rightPressed || snapshot.IsMouseDown(MouseButton.Middle); + io.MousePos = mousePosition; + io.MouseWheel = snapshot.WheelDelta; IReadOnlyList keyCharPresses = snapshot.KeyCharPresses; for (int i = 0; i < keyCharPresses.Count; i++)