Generate wxEVT_CHAR_HOOK events before accelerators
This is more consistent with the other ports and allows to use wxEVT_CHAR_HOOK handler to preempt processing of the accelerators (but notice that under macOS this only works for accelerators that are part of wxAcceleratorTable and not those associated with the menu items, as the latter ones are not handled by this code at all). Also simplify the code structure a little by getting rid of an unnecessary and more confusing than helpful "handled" variable.
This commit is contained in:
@@ -2568,9 +2568,8 @@ bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event )
|
||||
: "unknown",
|
||||
wxDumpWindow(this));
|
||||
|
||||
bool handled = false;
|
||||
|
||||
// moved the ordinary key event sending AFTER the accel evaluation
|
||||
if ( HandleWindowEvent(event) )
|
||||
return true;
|
||||
|
||||
#if wxUSE_ACCEL
|
||||
if (event.GetEventType() == wxEVT_CHAR_HOOK)
|
||||
@@ -2584,16 +2583,16 @@ bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event )
|
||||
wxEvtHandler * const handler = ancestor->GetEventHandler();
|
||||
|
||||
wxCommandEvent command_event( wxEVT_MENU, command );
|
||||
handled = handler->ProcessEvent( command_event );
|
||||
|
||||
if ( !handled )
|
||||
if ( !handler->ProcessEvent( command_event ) )
|
||||
{
|
||||
// accelerators can also be used with buttons, try them too
|
||||
command_event.SetEventType(wxEVT_BUTTON);
|
||||
handled = handler->ProcessEvent( command_event );
|
||||
handler->ProcessEvent( command_event );
|
||||
}
|
||||
|
||||
break;
|
||||
// In any case, the event was handled as it triggered an
|
||||
// accelerator.
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ancestor->IsTopNavigationDomain(wxWindow::Navigation_Accel))
|
||||
@@ -2604,10 +2603,7 @@ bool wxWindowMac::OSXHandleKeyEvent( wxKeyEvent& event )
|
||||
}
|
||||
#endif // wxUSE_ACCEL
|
||||
|
||||
if ( !handled )
|
||||
handled = HandleWindowEvent( event ) ;
|
||||
|
||||
return handled ;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* static */
|
||||
|
Reference in New Issue
Block a user