refactoring focus handling

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74107 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor 2013-06-04 07:22:54 +00:00
parent ba0cf6af6d
commit e17d84e1b2
2 changed files with 7 additions and 12 deletions

View 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 );
}
}

View 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