IO: Input queue trickling adjustment for touch screens. (#2702, #4921)

+ amend two comments in imgui.h
This commit is contained in:
ocornut 2023-04-04 20:07:57 +02:00
parent f070497cbd
commit c9fe7ebc7b
3 changed files with 14 additions and 2 deletions

View File

@ -58,6 +58,16 @@ Other changes:
Windows Close and Collapse Buttons.
- Misc: Fixed ImVec2 operator[] violating aliasing rules causing issue with Intel C++
compiler. (#6272) [@BayesBug]
- IO: Input queue trickling adjustment for touch screens. (#2702, #4921)
This fixes single-tapping to move simulated mouse and immediately click on a widget
that is using the ImGuiButtonFlags_AllowItemOverlap policy.
- This only works if the backend can distinguish TouchScreen vs Mouse.
See 'Demo->Tools->Metrics->Inputs->Mouse Source' to verify.
- Fixed tapping on BeginTabItem() on a touch-screen. (#2702)
- Fixed tapping on CollapsingHeader() with a close button on a touch-screen.
- Fixed tapping on TreeNode() using ImGuiTreeNodeFlags_AllowItemOverlap on a touch-screen.
- Fixed tapping on Selectable() using ImGuiSelectableFlags_AllowItemOverlap on a touch-screen.
- Fixed tapping on TableHeader() on a touch-screen.
- IO: Added io.AddMouseSourceEvent() and ImGuiMouseSource enum. This is to allow backend to
specify actual event source between Mouse/TouchScreen/Pen. (#2702, #2334, #2372, #3453, #5693)
- IO: Fixed support for calling io.AddXXXX functions fron inactive context (wrongly

View File

@ -8733,6 +8733,8 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
IM_ASSERT(button >= 0 && button < ImGuiMouseButton_COUNT);
if (trickle_fast_inputs && ((mouse_button_changed & (1 << button)) || mouse_wheeled))
break;
if (trickle_fast_inputs && e->MouseButton.MouseSource == ImGuiMouseSource_TouchScreen && mouse_moved) // #2702: TouchScreen have no initial hover.
break;
io.MouseDown[button] = e->MouseButton.Down;
io.MouseSource = e->MouseButton.MouseSource;
mouse_button_changed |= (1 << button);

View File

@ -167,7 +167,7 @@ struct ImGuiViewport; // A Platform Window (always only one in 'ma
// In Visual Studio IDE: CTRL+comma ("Edit.GoToAll") can follow symbols in comments, whereas CTRL+F12 ("Edit.GoToImplementation") cannot.
// With Visual Assist installed: ALT+G ("VAssistX.GoToImplementation") can also follow symbols in comments.
enum ImGuiKey : int; // -> enum ImGuiKey // Enum: A key identifier (ImGuiKey_XXX or ImGuiMod_XXX value)
enum ImGuiMouseSource : int; // -> enum ImGuiMouseSource // Enum; A mouse input source identifier (Mouse, TouchPad, TouchScreen, Pen)
enum ImGuiMouseSource : int; // -> enum ImGuiMouseSource // Enum; A mouse input source identifier (Mouse, TouchScreen, Pen)
typedef int ImGuiCol; // -> enum ImGuiCol_ // Enum: A color identifier for styling
typedef int ImGuiCond; // -> enum ImGuiCond_ // Enum: A condition for many Set*() functions
typedef int ImGuiDataType; // -> enum ImGuiDataType_ // Enum: A primary data type
@ -2049,7 +2049,7 @@ struct ImGuiIO
bool MouseDown[5]; // Mouse buttons: 0=left, 1=right, 2=middle + extras (ImGuiMouseButton_COUNT == 5). Dear ImGui mostly uses left and right buttons. Other buttons allow us to track if the mouse is being used by your application + available to user as a convenience via IsMouse** API.
float MouseWheel; // Mouse wheel Vertical: 1 unit scrolls about 5 lines text. >0 scrolls Up, <0 scrolls Down. Hold SHIFT to turn vertical scroll into horizontal scroll.
float MouseWheelH; // Mouse wheel Horizontal. >0 scrolls Left, <0 scrolls Right. Most users don't have a mouse with a horizontal wheel, may not be filled by all backends.
ImGuiMouseSource MouseSource; // Mouse actual input peripheral (Mouse/TouchPad/TouchScreen/Pen).
ImGuiMouseSource MouseSource; // Mouse actual input peripheral (Mouse/TouchScreen/Pen).
bool KeyCtrl; // Keyboard modifier down: Control
bool KeyShift; // Keyboard modifier down: Shift
bool KeyAlt; // Keyboard modifier down: Alt