mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-14 00:34:18 +00:00
IO: modify io.AddFocusEvent() to tolerate in/out for multi-viewports. Amend 2f40be6. (merged from docking) (#3532)
This commit is contained in:
parent
fba756176d
commit
bbb95a5e06
2 changed files with 19 additions and 7 deletions
22
imgui.cpp
22
imgui.cpp
|
|
@ -1185,13 +1185,8 @@ void ImGuiIO::ClearInputCharacters()
|
|||
InputQueueCharacters.resize(0);
|
||||
}
|
||||
|
||||
void ImGuiIO::AddFocusEvent(bool focused)
|
||||
void ImGuiIO::ClearInputKeys()
|
||||
{
|
||||
if (focused)
|
||||
return;
|
||||
|
||||
// Clear buttons state when focus is lost
|
||||
// (this is useful so e.g. releasing Alt after focus loss on Alt-Tab doesn't trigger the Alt menu toggle)
|
||||
memset(KeysDown, 0, sizeof(KeysDown));
|
||||
for (int n = 0; n < IM_ARRAYSIZE(KeysDownDuration); n++)
|
||||
KeysDownDuration[n] = KeysDownDurationPrev[n] = -1.0f;
|
||||
|
|
@ -1201,6 +1196,13 @@ void ImGuiIO::AddFocusEvent(bool focused)
|
|||
NavInputsDownDuration[n] = NavInputsDownDurationPrev[n] = -1.0f;
|
||||
}
|
||||
|
||||
void ImGuiIO::AddFocusEvent(bool focused)
|
||||
{
|
||||
// We intentionally overwrite this and process in NewFrame(), in order to give a chance
|
||||
// to multi-viewports backends to queue AddFocusEvent(false),AddFocusEvent(true) in same frame.
|
||||
AppFocusLost = !focused;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] MISC HELPERS/UTILITIES (Geometry functions)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -4070,6 +4072,14 @@ void ImGui::NewFrame()
|
|||
g.DragDropWithinTarget = false;
|
||||
g.DragDropHoldJustPressedId = 0;
|
||||
|
||||
// Clear buttons state when focus is lost
|
||||
// (this is useful so e.g. releasing Alt after focus loss on Alt-Tab doesn't trigger the Alt menu toggle)
|
||||
if (g.IO.AppFocusLost)
|
||||
{
|
||||
g.IO.ClearInputKeys();
|
||||
g.IO.AppFocusLost = false;
|
||||
}
|
||||
|
||||
// Update keyboard input state
|
||||
// Synchronize io.KeyMods with individual modifiers io.KeyXXX bools
|
||||
g.IO.KeyMods = GetMergedKeyModFlags();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue