Explorar el Código

don't eat key events at all
only eat char events when Imgui wants keyboard control.
This lets the calling applications get access to key events if they need them and they check the IO flags.

Jeff Myers hace 1 año
padre
commit
3d8ece299d
Se han modificado 1 ficheros con 14 adiciones y 11 borrados
  1. 14 11
      rlImGui.cpp

+ 14 - 11
rlImGui.cpp

@@ -728,14 +728,14 @@ bool ImGui_ImplRaylib_ProcessEvents(void)
 		io.AddKeyEvent(ImGuiMod_Super, superDown);
 	LastSuperPressed = superDown;
 
-	// get the pressed keys, they are in event order
-	int keyId = GetKeyPressed();
-	while (keyId != 0)
+	// get the pressed keys, just walk the keys so we don
+	for (int keyId = KEY_NULL; keyId < KeyboardKey::KEY_KP_EQUAL; keyId++)
 	{
+        if (!IsKeyPressed(keyId))
+            continue;
 		auto keyItr = RaylibKeyMap.find(KeyboardKey(keyId));
 		if (keyItr != RaylibKeyMap.end())
 			io.AddKeyEvent(keyItr->second, true);
-		keyId = GetKeyPressed();
 	}
 
 	// look for any keys that were down last frame and see if they were down and are released
@@ -745,13 +745,16 @@ bool ImGui_ImplRaylib_ProcessEvents(void)
 			io.AddKeyEvent(keyItr.second, false);
 	}
 
-	// add the text input in order
-	unsigned int pressed = GetCharPressed();
-	while (pressed != 0)
-	{
-		io.AddInputCharacter(pressed);
-		pressed = GetCharPressed();
-	}
+    if (io.WantCaptureKeyboard)
+    {
+        // add the text input in order
+        unsigned int pressed = GetCharPressed();
+        while (pressed != 0)
+        {
+            io.AddInputCharacter(pressed);
+            pressed = GetCharPressed();
+        }
+    }
 
     if (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad && IsGamepadAvailable(0))
     {