Jelajahi Sumber

Nav, IO: SetNextFrameWantCaptureKeyboard(false) calls are not overrided back to true when navigation is enabled. (#6997)

ocornut 1 tahun lalu
induk
melakukan
6f171a066d
2 mengubah file dengan 5 tambahan dan 4 penghapusan
  1. 2 0
      docs/CHANGELOG.txt
  2. 3 4
      imgui.cpp

+ 2 - 0
docs/CHANGELOG.txt

@@ -46,6 +46,8 @@ Other changes:
 
 - Windows: BeginChild(): Fixed auto-resizing erroneously limiting size to host viewport
   minus padding. There are no limit to a child width/height. (#7063) [@Devyre]
+- Nav, IO: SetNextFrameWantCaptureKeyboard(false) calls are not overrided back to true when
+  navigation is enabled. SetNextFrameWantCaptureKeyboard() is always higher priority. (#6997)
 - Drag and Drop: Fixed drop target highlight on items temporarily pushing a widened clip rect
   (namely Selectables and Treenodes using SpanAllColumn flag) so the highlight properly covers
   all columns. (#7049, #4281, #3272)

+ 3 - 4
imgui.cpp

@@ -4566,12 +4566,11 @@ void ImGui::UpdateHoveredWindowAndCaptureFlags()
     }
 
     // Update io.WantCaptureKeyboard for the user application (true = dispatch keyboard info to Dear ImGui only, false = dispatch keyboard info to Dear ImGui + underlying app)
-    if (g.WantCaptureKeyboardNextFrame != -1)
-        io.WantCaptureKeyboard = (g.WantCaptureKeyboardNextFrame != 0);
-    else
-        io.WantCaptureKeyboard = (g.ActiveId != 0) || (modal_window != NULL);
+    io.WantCaptureKeyboard = (g.ActiveId != 0) || (modal_window != NULL);
     if (io.NavActive && (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) && !(io.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard))
         io.WantCaptureKeyboard = true;
+    if (g.WantCaptureKeyboardNextFrame != -1) // Manual override
+        io.WantCaptureKeyboard = (g.WantCaptureKeyboardNextFrame != 0);
 
     // Update io.WantTextInput flag, this is to allow systems without a keyboard (e.g. mobile, hand-held) to show a software keyboard if possible
     io.WantTextInput = (g.WantTextInputNextFrame != -1) ? (g.WantTextInputNextFrame != 0) : false;