Stop handling performKeyEquivalent: in wxOSX

We can't handle the accelerators (known as "key equivalents" in Cocoa)
in this function because it is called for the views in top to bottom
order, while wx semantics is for accelerators to be handled in the
accelerator table closest to the focused window.

So just remove this code and rely on accelerator handling happening in
wxWindowMac::OSXHandleKeyEvent() instead.

Closes #13937.
This commit is contained in:
Vadim Zeitlin
2019-10-27 00:02:29 +02:00
parent df689e739a
commit 87bba02fef
3 changed files with 0 additions and 57 deletions

View File

@@ -185,7 +185,6 @@ public :
virtual void keyEvent(WX_NSEvent event, WXWidget slf, void* _cmd);
virtual void insertText(NSString* text, WXWidget slf, void* _cmd);
virtual void doCommandBySelector(void* sel, WXWidget slf, void* _cmd);
virtual bool performKeyEquivalent(WX_NSEvent event, WXWidget slf, void* _cmd);
virtual bool acceptsFirstResponder(WXWidget slf, void* _cmd);
virtual bool becomeFirstResponder(WXWidget slf, void* _cmd);
virtual bool resignFirstResponder(WXWidget slf, void* _cmd);

View File

@@ -368,12 +368,6 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil;
[super flagsChanged:event];
}
- (BOOL) performKeyEquivalent:(NSEvent*) event
{
BOOL retval = [super performKeyEquivalent:event];
return retval;
}
- (void) insertText:(id) str
{
// We should never generate char events for the text being inserted

View File

@@ -1197,15 +1197,6 @@ void wxOSX_touchesEnded(NSView* self, SEL _cmd, NSEvent *event)
}
#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10
BOOL wxOSX_performKeyEquivalent(NSView* self, SEL _cmd, NSEvent *event)
{
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
if (impl == NULL)
return NO;
return impl->performKeyEquivalent(event, self, _cmd);
}
BOOL wxOSX_acceptsFirstResponder(NSView* self, SEL _cmd)
{
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
@@ -2212,45 +2203,6 @@ void wxWidgetCocoaImpl::doCommandBySelector(void* sel, WXWidget slf, void* _cmd)
}
}
bool wxWidgetCocoaImpl::performKeyEquivalent(WX_NSEvent event, WXWidget slf, void *_cmd)
{
wxLogTrace(TRACE_KEYS, "Got %s for %s",
wxDumpSelector((SEL)_cmd), wxDumpNSView(slf));
bool handled = false;
wxKeyEvent wxevent(wxEVT_KEY_DOWN);
SetupKeyEvent( wxevent, event );
// because performKeyEquivalent is going up the entire view hierarchy, we don't have to
// walk up the ancestors ourselves but let cocoa do it
#if wxUSE_ACCEL
int command = m_wxPeer->GetAcceleratorTable()->GetCommand( wxevent );
if (command != -1)
{
wxEvtHandler * const handler = m_wxPeer->GetEventHandler();
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_BUTTON);
handled = handler->ProcessEvent( command_event );
}
}
#endif // wxUSE_ACCEL
if ( !handled )
{
wxOSX_PerformKeyEventHandlerPtr superimpl = (wxOSX_PerformKeyEventHandlerPtr) [[slf superclass] instanceMethodForSelector:(SEL)_cmd];
return superimpl(slf, (SEL)_cmd, event);
}
return YES;
}
bool wxWidgetCocoaImpl::acceptsFirstResponder(WXWidget slf, void *_cmd)
{
if ( HasUserKeyHandling() )
@@ -2531,8 +2483,6 @@ void wxOSXCocoaClassAddWXMethods(Class c, wxOSXSkipOverrides skipFlags)
wxOSX_CLASS_ADD_METHOD(c, @selector(insertText:), (IMP) wxOSX_insertText, "v@:@" )
wxOSX_CLASS_ADD_METHOD(c, @selector(performKeyEquivalent:), (IMP) wxOSX_performKeyEquivalent, "c@:@" )
wxOSX_CLASS_ADD_METHOD(c, @selector(acceptsFirstResponder), (IMP) wxOSX_acceptsFirstResponder, "c@:" )
wxOSX_CLASS_ADD_METHOD(c, @selector(becomeFirstResponder), (IMP) wxOSX_becomeFirstResponder, "c@:" )
wxOSX_CLASS_ADD_METHOD(c, @selector(resignFirstResponder), (IMP) wxOSX_resignFirstResponder, "c@:" )