2
0
Эх сурвалжийг харах

Nav: workaround to kindly handle ALT-TAB without detecting TAB-release on backends that clear all keys on unfocus. (#787)

omar 7 жил өмнө
parent
commit
bed6ef03f5
2 өөрчлөгдсөн 6 нэмэгдсэн , 2 устгасан
  1. 2 0
      TODO.txt
  2. 4 2
      imgui.cpp

+ 2 - 0
TODO.txt

@@ -238,6 +238,8 @@ It's mostly a bunch of personal notes, probably incomplete. Feel free to query i
  - focus: preserve ActiveId/focus stack state, e.g. when opening a menu and close it, previously selected InputText() focus gets restored (#622)
  - focus: SetKeyboardFocusHere() on with >= 0 offset could be done on same frame (else latch and modulate on beginning of next frame)
  - focus: unable to use SetKeyboardFocusHere() on clipped widgets. (#787)
+
+ - inputs: we need an explicit flag about whether the imgui window is focused, to be able to distinguish focused key releases vs alt-tabbing all release behaviors.
  - inputs: rework IO system to be able to pass actual ordered/timestamped events. use an event queue? (~#335, #71)
  - inputs: support track pad style scrolling & slider edit.
 

+ 4 - 2
imgui.cpp

@@ -2780,9 +2780,11 @@ static void ImGui::NavUpdateWindowing()
             apply_focus_window = g.NavWindowingTarget;
     }
 
-    // Keyboard: Press and release ALT to toggle menu layer
+    // Keyboard: Press and Release ALT to toggle menu layer
+    // FIXME: We lack an explicit IO variable for "is the imgui window focused", so compare mouse validity to detect the common case of backend clearing releases all keys on ALT-TAB
     if ((g.ActiveId == 0 || g.ActiveIdAllowOverlap) && IsNavInputPressed(ImGuiNavInput_KeyMenu, ImGuiInputReadMode_Released))
-        apply_toggle_layer = true;
+        if (IsMousePosValid(&g.IO.MousePos) == IsMousePosValid(&g.IO.MousePosPrev))
+            apply_toggle_layer = true;
 
     // Move window
     if (g.NavWindowingTarget && !(g.NavWindowingTarget->Flags & ImGuiWindowFlags_NoMove))