]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/cocoa/window.mm
fixes potential crash under gatekeeper
[wxWidgets.git] / src / osx / cocoa / window.mm
index dfb8035dac6933364cb7cb92b76d68a95e05b28c..9bda9421f09769db33b39e066a7f9b80bc5665b9 100644 (file)
@@ -809,6 +809,14 @@ void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEve
 }
 #endif
 
+- (BOOL) canBecomeKeyView
+{
+    wxWidgetCocoaImpl* viewimpl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+    if ( viewimpl && viewimpl->IsUserPane() && viewimpl->GetWXPeer() )
+        return viewimpl->GetWXPeer()->AcceptsFocus();
+    return NO;
+}
+
 @end // wxNSView
 
 //
@@ -1170,6 +1178,15 @@ typedef BOOL (*wxOSX_FocusHandlerPtr)(NSView* self, SEL _cmd);
 
 void wxWidgetCocoaImpl::mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd)
 {
+    // we are getting moved events for all windows in the hierarchy, not something wx expects
+    // therefore we only handle it for the deepest child in the hierarchy
+    if ( [event type] == NSMouseMoved )
+    {
+        NSView* hitview = [[[slf window] contentView] hitTest:[event locationInWindow]];
+        if ( hitview == NULL || hitview != slf)
+            return;
+    }
+    
     if ( !DoHandleMouseEvent(event) )
     {
         // for plain NSView mouse events would propagate to parents otherwise
@@ -1219,9 +1236,14 @@ bool wxWidgetCocoaImpl::SetupCursor(WX_NSEvent event)
         
         while ( cursorTarget && !cursorTarget->MacSetupCursor( cursorPoint ) )
         {
+            // at least in GTK cursor events are not propagated either ...
+#if 1
+            cursorTarget = NULL;
+#else
             cursorTarget = cursorTarget->GetParent() ;
             if ( cursorTarget )
                 cursorPoint += cursorTarget->GetPosition();
+#endif
         }
         
         return cursorTarget != NULL;
@@ -1273,14 +1295,14 @@ bool wxWidgetCocoaImpl::performKeyEquivalent(WX_NSEvent event, WXWidget slf, voi
     {
         wxEvtHandler * const handler = m_wxPeer->GetEventHandler();
         
-        wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command );
+        wxCommandEvent command_event( wxEVT_MENU, command );
         command_event.SetEventObject( wxevent.GetEventObject() );
         handled = handler->ProcessEvent( command_event );
         
         if ( !handled )
         {
             // accelerators can also be used with buttons, try them too
-            command_event.SetEventType(wxEVT_COMMAND_BUTTON_CLICKED);
+            command_event.SetEventType(wxEVT_BUTTON);
             handled = handler->ProcessEvent( command_event );
         }
     }
@@ -1330,6 +1352,9 @@ bool wxWidgetCocoaImpl::resignFirstResponder(WXWidget slf, void *_cmd)
     NSView* otherView = FindFocus();
     wxWidgetImpl* otherWindow = FindFromWXWidget(otherView);
 
+    // CS: the fix for #12267 leads to missed focus events like in #14938 , as #12267 doesn't seem to happen anymore even
+    // without the fix, I'm turning it off, if it still is needed we should only use it in case of the wxGridCellTextEditor 
+#if 0
     // It doesn't make sense to notify about the loss of focus if we're not
     // really losing it and the window which has just gained focus is the same
     // one as this window itself. Of course, this should never happen in the
@@ -1337,7 +1362,8 @@ bool wxWidgetCocoaImpl::resignFirstResponder(WXWidget slf, void *_cmd)
     // enter into an infinite recursion, see #12267.
     if ( otherWindow == this )
         return r;
-
+#endif
+    
     // NSTextViews have an editor as true responder, therefore the might get the
     // resign notification if their editor takes over, don't trigger any event then
     if ( r && !m_hasEditor)
@@ -2500,7 +2526,7 @@ void wxWidgetCocoaImpl::InstallEventHandler( WXWidget control )
 
     }
     NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited|NSTrackingCursorUpdate|NSTrackingMouseMoved|NSTrackingActiveAlways|NSTrackingInVisibleRect;
-        NSTrackingArea* area = [[NSTrackingArea alloc] initWithRect: NSZeroRect options: options owner: m_osxView userInfo: nil];
+    NSTrackingArea* area = [[NSTrackingArea alloc] initWithRect: NSZeroRect options: options owner: m_osxView userInfo: nil];
     [m_osxView addTrackingArea: area];
     [area release];
  }