avoiding focus lost events when a different subview gets focused, see #14042

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74100 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2013-06-03 17:49:03 +00:00
parent 19736e6452
commit ea9ae179ed

View File

@@ -1349,21 +1349,19 @@ bool wxWidgetCocoaImpl::resignFirstResponder(WXWidget slf, void *_cmd)
BOOL r = superimpl(slf, (SEL)_cmd); BOOL r = superimpl(slf, (SEL)_cmd);
NSResponder * responder = wxNonOwnedWindowCocoaImpl::GetNextFirstResponder(); NSResponder * responder = wxNonOwnedWindowCocoaImpl::GetNextFirstResponder();
NSView* otherView = [responder isKindOfClass:[NSView class]] ? (NSView*)responder : nil; NSView* otherView = GetViewFromResponder(responder);
wxWidgetImpl* otherWindow = FindFromWXWidget(otherView); 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 // NSScrollViews can have their subviews like NSClipView getting focus
// without the fix, I'm turning it off, if it still is needed we should only use it in case of the wxGridCellTextEditor // therefore check and use the NSScrollView peer in that case
#if 0 if ( otherWindow == NULL && [[otherView superview] isKindOfClass:[NSScrollView class]])
// It doesn't make sense to notify about the loss of focus if we're not otherWindow = FindFromWXWidget([otherView superview]);
// 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 // It doesn't make sense to notify about the loss of focus if it's the same
// first place but somehow it does in wxGrid code and without this check we // control in the end, and just a different subview
// enter into an infinite recursion, see #12267.
if ( otherWindow == this ) if ( otherWindow == this )
return r; return r;
#endif
// NSTextViews have an editor as true responder, therefore the might get the // 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 // resign notification if their editor takes over, don't trigger any event then