From e17d84e1b2189d11891d41b3809903eb22d1b91d Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Tue, 4 Jun 2013 07:22:54 +0000 Subject: [PATCH] refactoring focus handling git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74107 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/cocoa/textctrl.mm | 12 ++++++------ src/osx/cocoa/window.mm | 7 +------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 4d4398e2d2..760257f4f4 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -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 ); } } diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index ea2475e0a5..e7d038a84c 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -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 -- 2.45.2