Browse Source

Backends: OSX: ImGui_ImplOSX_HandleEvent() only process event for window containing our viewports. Amend 7ac99a4 for docking. (#8644)

ocornut 2 months ago
parent
commit
d896eab166
1 changed files with 7 additions and 2 deletions
  1. 7 2
      backends/imgui_impl_osx.mm

+ 7 - 2
backends/imgui_impl_osx.mm

@@ -699,10 +699,15 @@ static ImGuiMouseSource GetMouseSource(NSEvent* event)
 static bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
 {
     // Only process events from the window containing ImGui view
-    if (event.window != view.window)
+    void* event_handle = (__bridge void*)(event.window);
+    void* view_handle = (__bridge void*)(view.window);
+    if (event_handle == nullptr || view_handle == nullptr)
+        return false;
+    ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle(view_handle);
+    if (viewport == nullptr || viewport->PlatformHandleRaw != event_handle)
         return false;
-    ImGuiIO& io = ImGui::GetIO();
 
+    ImGuiIO& io = ImGui::GetIO();
     if (event.type == NSEventTypeLeftMouseDown || event.type == NSEventTypeRightMouseDown || event.type == NSEventTypeOtherMouseDown)
     {
         int button = (int)[event buttonNumber];