]> git.saurik.com Git - wxWidgets.git/commitdiff
refactoring focus handling
authorStefan Csomor <csomor@advancedconcepts.ch>
Tue, 4 Jun 2013 07:22:54 +0000 (07:22 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Tue, 4 Jun 2013 07:22:54 +0000 (07:22 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74107 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/osx/cocoa/textctrl.mm
src/osx/cocoa/window.mm

index 4d4398e2d29d464cf10404307675223b51e9bef7..760257f4f4547e0afa9139dd416ca4331cf1fe1d 100644 (file)
@@ -183,9 +183,9 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
     if ( impl )
     {
         NSResponder * responder = wxNonOwnedWindowCocoaImpl::GetNextFirstResponder();
-        NSView* otherView = [responder isKindOfClass:[NSView class]] ? (NSView*)responder : nil;
+        NSView* otherView = wxOSXGetViewFromResponder(responder);
         
-        wxWidgetImpl* otherWindow = impl->FindFromWXWidget(otherView);
+        wxWidgetImpl* otherWindow = impl->FindBestFromWXWidget(otherView);
         impl->DoNotifyFocusEvent( false, otherWindow );
     }
 }
@@ -341,9 +341,9 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
     if ( impl )
     {
         NSResponder * responder = wxNonOwnedWindowCocoaImpl::GetNextFirstResponder();
-        NSView* otherView = [responder isKindOfClass:[NSView class]] ? (NSView*)responder : nil;
+        NSView* otherView = wxOSXGetViewFromResponder(responder);
         
-        wxWidgetImpl* otherWindow = impl->FindFromWXWidget(otherView);
+        wxWidgetImpl* otherWindow = impl->FindBestFromWXWidget(otherView);
         impl->DoNotifyFocusEvent( false, otherWindow );
     }
 }
@@ -515,9 +515,9 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
         }
 
         NSResponder * responder = wxNonOwnedWindowCocoaImpl::GetNextFirstResponder();
-        NSView* otherView = [responder isKindOfClass:[NSView class]] ? (NSView*)responder : nil;
+        NSView* otherView = wxOSXGetViewFromResponder(responder);
         
-        wxWidgetImpl* otherWindow = impl->FindFromWXWidget(otherView);
+        wxWidgetImpl* otherWindow = impl->FindBestFromWXWidget(otherView);
         impl->DoNotifyFocusEvent( false, otherWindow );
     }
 }
index ea2475e0a5945a4d93f4ce70e6cb770eceeadc64..e7d038a84c09654f37db213afee71c5284d7bcb3 100644 (file)
@@ -1364,12 +1364,7 @@ bool wxWidgetCocoaImpl::resignFirstResponder(WXWidget slf, void *_cmd)
     NSResponder * responder = wxNonOwnedWindowCocoaImpl::GetNextFirstResponder();
     NSView* otherView = wxOSXGetViewFromResponder(responder);
 
-    wxWidgetImpl* otherWindow = FindFromWXWidget(otherView);
-    
-    // NSScrollViews can have their subviews like NSClipView getting focus
-    // therefore check and use the NSScrollView peer in that case
-    if ( otherWindow == NULL && [[otherView superview] isKindOfClass:[NSScrollView class]])
-        otherWindow = FindFromWXWidget([otherView superview]);
+    wxWidgetImpl* otherWindow = FindBestFromWXWidget(otherView);
     
     // It doesn't make sense to notify about the loss of focus if it's the same
     // control in the end, and just a different subview