mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 12:08:47 +02:00
IO: Added AddMousePosEvent(), AddMouseButtonEvent(), AddMouseWheelEvent() api + updated all Backends. (#4858) (input queue code will be next commit)
Details: note that SDL, OSX and GLFW backends removed recording of MouseJustPressed[] which will be unnecessary with input queue (which is the NEXT commit). (#2787, #1992, #3383, #2525, #1320)
This commit is contained in:
28
imgui.cpp
28
imgui.cpp
@ -1262,7 +1262,7 @@ void ImGuiIO::AddKeyEvent(ImGuiKey key, bool down)
|
||||
KeysData[keydata_index].Down = down;
|
||||
}
|
||||
|
||||
// [Optional] Call add AddKeyEvent().
|
||||
// [Optional] Call after AddKeyEvent().
|
||||
// Specify native keycode, scancode + Specify index for legacy <1.87 IsKeyXXX() functions with native indices.
|
||||
// If you are writing a backend in 2022 or don't use IsKeyXXX() with native values that are not ImGuiKey values, you can avoid calling this.
|
||||
void ImGuiIO::SetKeyEventNativeData(ImGuiKey key, int native_keycode, int native_scancode, int native_legacy_index)
|
||||
@ -1294,6 +1294,32 @@ void ImGuiIO::AddKeyModsEvent(ImGuiKeyModFlags modifiers)
|
||||
KeySuper = (modifiers & ImGuiKeyModFlags_Super) != 0;
|
||||
}
|
||||
|
||||
// Queue a mouse move event
|
||||
void ImGuiIO::AddMousePosEvent(float x, float y)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
||||
g.IO.MousePos = ImVec2(x, y);
|
||||
}
|
||||
|
||||
void ImGuiIO::AddMouseWheelEvent(float wheel_x, float wheel_y)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
||||
if (wheel_x == 0.0f && wheel_y == 0.0f)
|
||||
return;
|
||||
g.IO.MouseWheelH += wheel_x;
|
||||
g.IO.MouseWheel += wheel_y;
|
||||
}
|
||||
|
||||
void ImGuiIO::AddMouseButtonEvent(int mouse_button, bool down)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(&g.IO == this && "Can only add events to current context.");
|
||||
IM_ASSERT(mouse_button >= 0 && mouse_button < ImGuiMouseButton_COUNT);
|
||||
g.IO.MouseDown[mouse_button] = down;
|
||||
}
|
||||
|
||||
void ImGuiIO::AddFocusEvent(bool focused)
|
||||
{
|
||||
// We intentionally overwrite this and process in NewFrame(), in order to give a chance
|
||||
|
Reference in New Issue
Block a user