Internals: Track ActiveIdHasBeenPressed (similar to ActiveIdHasBeenEdited). This is currently mostly for the benefit of the range_select branch. (#1861)
diff --git a/imgui.cpp b/imgui.cpp
index ba54366..b38c50a 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -2636,6 +2636,7 @@
if (g.ActiveIdIsJustActivated)
{
g.ActiveIdTimer = 0.0f;
+ g.ActiveIdHasBeenPressed = false;
g.ActiveIdHasBeenEdited = false;
if (id != 0)
{
diff --git a/imgui_internal.h b/imgui_internal.h
index 6869070..76c3ce5 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -423,7 +423,7 @@
ImGuiNavHighlightFlags_None = 0,
ImGuiNavHighlightFlags_TypeDefault = 1 << 0,
ImGuiNavHighlightFlags_TypeThin = 1 << 1,
- ImGuiNavHighlightFlags_AlwaysDraw = 1 << 2,
+ ImGuiNavHighlightFlags_AlwaysDraw = 1 << 2, // Draw rectangular highlight if (g.NavId == id) _even_ when using the mouse.
ImGuiNavHighlightFlags_NoRounding = 1 << 3
};
@@ -792,6 +792,7 @@
float ActiveIdTimer;
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
+ bool ActiveIdHasBeenPressed; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch.
bool ActiveIdHasBeenEdited; // Was the value associated to the widget Edited over the course of the Active state.
bool ActiveIdPreviousFrameIsAlive;
bool ActiveIdPreviousFrameHasBeenEdited;
@@ -897,7 +898,8 @@
ImVector<char> PrivateClipboard; // If no custom clipboard handler is defined
// Platform support
- ImVec2 PlatformImePos, PlatformImeLastPos; // Cursor position request & last passed to the OS Input Method Editor
+ ImVec2 PlatformImePos; // Cursor position request & last passed to the OS Input Method Editor
+ ImVec2 PlatformImeLastPos;
// Settings
bool SettingsLoaded;
@@ -948,6 +950,7 @@
ActiveIdTimer = 0.0f;
ActiveIdIsJustActivated = false;
ActiveIdAllowOverlap = false;
+ ActiveIdHasBeenPressed = false;
ActiveIdHasBeenEdited = false;
ActiveIdPreviousFrameIsAlive = false;
ActiveIdPreviousFrameHasBeenEdited = false;
diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp
index feeb3f9..283a17d 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -507,6 +507,8 @@
bool held = false;
if (g.ActiveId == id)
{
+ if (pressed)
+ g.ActiveIdHasBeenPressed = true;
if (g.ActiveIdSource == ImGuiInputSource_Mouse)
{
if (g.ActiveIdIsJustActivated)