IO: Input queue trickling adjustment for touch screens. (#2702, #4921)
+ amend two comments in imgui.h
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index a676048..a96410b 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -58,6 +58,16 @@
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
diff --git a/imgui.cpp b/imgui.cpp
index 3275ede..4e3b605 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -8733,6 +8733,8 @@
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);
diff --git a/imgui.h b/imgui.h
index c78bec7..c974d9c 100644
--- a/imgui.h
+++ b/imgui.h
@@ -167,7 +167,7 @@
// 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 @@
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