diff --git a/imgui.cpp b/imgui.cpp index 2e1b7810cac5..83f9418ce555 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3113,6 +3113,7 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window) g.ActiveId = id; g.ActiveIdAllowOverlap = false; g.ActiveIdNoClearOnFocusLoss = false; + g.ActiveIdWindowIsJustChanged = (g.ActiveIdWindow != window); g.ActiveIdWindow = window; g.ActiveIdHasBeenEditedThisFrame = false; if (id) @@ -3930,7 +3931,9 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags() g.IO.WantCaptureKeyboard = true; // Update io.WantTextInput flag, this is to allow systems without a keyboard (e.g. mobile, hand-held) to show a software keyboard if possible + const bool oldWantTextInput = g.IO.WantTextInput; g.IO.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false; + g.IO.WantTextInputIsJustChanged = (g.IO.WantTextInput != oldWantTextInput); } ImGuiKeyModFlags ImGui::GetMergedKeyModFlags() diff --git a/imgui.h b/imgui.h index 9eeabbe9a242..8cb279f4d7f7 100644 --- a/imgui.h +++ b/imgui.h @@ -1865,6 +1865,7 @@ struct ImGuiIO bool WantCaptureMouse; // Set when Dear ImGui will use mouse inputs, in this case do not dispatch them to your main game/application (either way, always pass on mouse inputs to imgui). (e.g. unclicked mouse is hovering over an imgui window, widget is active, mouse was clicked over an imgui window, etc.). bool WantCaptureKeyboard; // Set when Dear ImGui will use keyboard inputs, in this case do not dispatch them to your main game/application (either way, always pass keyboard inputs to imgui). (e.g. InputText active, or an imgui window is focused and navigation is enabled, etc.). bool WantTextInput; // Mobile/console: when set, you may display an on-screen keyboard. This is set by Dear ImGui when it wants textual keyboard input to happen (e.g. when a InputText widget is active). + bool WantTextInputIsJustChanged; // Set when WantTextInput is changed. bool WantSetMousePos; // MousePos has been altered, backend should reposition mouse on next frame. Rarely used! Set only when ImGuiConfigFlags_NavEnableSetMousePos flag is enabled. bool WantSaveIniSettings; // When manual .ini load/save is active (io.IniFilename == NULL), this will be set to notify your application that you can call SaveIniSettingsToMemory() and save yourself. Important: clear io.WantSaveIniSettings yourself after saving! bool NavActive; // Keyboard/Gamepad navigation is currently allowed (will handle ImGuiKey_NavXXX events) = a window is focused and it doesn't use the ImGuiWindowFlags_NoNavInputs flag. diff --git a/imgui_internal.h b/imgui_internal.h index 828f9e31928f..9a7a9d37ce56 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1460,6 +1460,7 @@ struct ImGuiContext ImU64 ActiveIdUsingKeyInputMask; // Active widget will want to read those key inputs. When we grow the ImGuiKey enum we'll need to either to order the enum to make useful keys come first, either redesign this into e.g. a small array. ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior) ImGuiWindow* ActiveIdWindow; + bool ActiveIdWindowIsJustChanged; ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard) int ActiveIdMouseButton; ImGuiID ActiveIdPreviousFrame; @@ -1692,6 +1693,7 @@ struct ImGuiContext ActiveIdUsingKeyInputMask = 0x00; ActiveIdClickOffset = ImVec2(-1, -1); ActiveIdWindow = NULL; + ActiveIdWindowIsJustChanged = false; ActiveIdSource = ImGuiInputSource_None; ActiveIdMouseButton = -1; ActiveIdPreviousFrame = 0;