浏览代码

Backends: OSX: ImGui_ImplOSX_HandleEvent() only process event for window containing our view. (#8644)

ocornut 4 月之前
父节点
当前提交
7ac99a4366
共有 2 个文件被更改,包括 6 次插入0 次删除
  1. 4 0
      backends/imgui_impl_osx.mm
  2. 2 0
      docs/CHANGELOG.txt

+ 4 - 0
backends/imgui_impl_osx.mm

@@ -31,6 +31,7 @@
 
 
 // CHANGELOG
 // CHANGELOG
 // (minor and older changes stripped away, please see git history for details)
 // (minor and older changes stripped away, please see git history for details)
+//  2025-06-12: ImGui_ImplOSX_HandleEvent() only process event for window containing our view. (#8644)
 //  2025-03-21: Fill gamepad inputs and set ImGuiBackendFlags_HasGamepad regardless of ImGuiConfigFlags_NavEnableGamepad being set.
 //  2025-03-21: Fill gamepad inputs and set ImGuiBackendFlags_HasGamepad regardless of ImGuiConfigFlags_NavEnableGamepad being set.
 //  2025-01-20: Removed notification observer when shutting down. (#8331)
 //  2025-01-20: Removed notification observer when shutting down. (#8331)
 //  2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
 //  2024-08-22: moved some OS/backend related function pointers from ImGuiIO to ImGuiPlatformIO:
@@ -663,6 +664,9 @@ static ImGuiMouseSource GetMouseSource(NSEvent* event)
 
 
 static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
 static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
 {
 {
+    // Only process events from the window containing ImGui view
+    if (event.window != view.window)
+        return false;
     ImGuiIO& io = ImGui::GetIO();
     ImGuiIO& io = ImGui::GetIO();
 
 
     if (event.type == NSEventTypeLeftMouseDown || event.type == NSEventTypeRightMouseDown || event.type == NSEventTypeOtherMouseDown)
     if (event.type == NSEventTypeLeftMouseDown || event.type == NSEventTypeRightMouseDown || event.type == NSEventTypeOtherMouseDown)

+ 2 - 0
docs/CHANGELOG.txt

@@ -407,6 +407,8 @@ Other changes:
     memory ownership change. (#8530, #7801) [@Green-Sky]
     memory ownership change. (#8530, #7801) [@Green-Sky]
   - Backends: SDL3: honor ImGuiPlatformImeData->WantTextInput as an alternative
   - Backends: SDL3: honor ImGuiPlatformImeData->WantTextInput as an alternative
     way to call SDL_StartTextInput(), without IME being necessarily visible. (#8584)
     way to call SDL_StartTextInput(), without IME being necessarily visible. (#8584)
+  - Backends: OSX: ImGui_ImplOSX_HandleEvent() only process event for window containing
+    our view. (#8644) [@BingoXuan]
 - Examples:
 - Examples:
   - Examples: Made many examples DPI aware by default.
   - Examples: Made many examples DPI aware by default.
     The single-viewport is basically:
     The single-viewport is basically: