Handle accelerators earlier in keyboard processing code in wxGTK.
Translate key presses to accelerators before sending wxEVT_KEY_DOWN. Also check for accelerators even for the key combinations handled by IM, normally IM should take precedence but IM seems to intercept common keys such as Shift+anything which it makes sense to use as accelerators. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72176 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -951,8 +951,37 @@ gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit KEY_DOWN event
|
// Next check for accelerators.
|
||||||
ret = win->HandleWindowEvent( event );
|
#if wxUSE_ACCEL
|
||||||
|
wxWindowGTK *ancestor = win;
|
||||||
|
while (ancestor)
|
||||||
|
{
|
||||||
|
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
|
||||||
|
if (command != -1)
|
||||||
|
{
|
||||||
|
wxCommandEvent menu_event( wxEVT_COMMAND_MENU_SELECTED, command );
|
||||||
|
ret = ancestor->HandleWindowEvent( menu_event );
|
||||||
|
|
||||||
|
if ( !ret )
|
||||||
|
{
|
||||||
|
// if the accelerator wasn't handled as menu event, try
|
||||||
|
// it as button click (for compatibility with other
|
||||||
|
// platforms):
|
||||||
|
wxCommandEvent button_event( wxEVT_COMMAND_BUTTON_CLICKED, command );
|
||||||
|
ret = ancestor->HandleWindowEvent( button_event );
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ancestor->IsTopLevel())
|
||||||
|
break;
|
||||||
|
ancestor = ancestor->GetParent();
|
||||||
|
}
|
||||||
|
#endif // wxUSE_ACCEL
|
||||||
|
|
||||||
|
// If not an accelerator, then emit KEY_DOWN event
|
||||||
|
if ( !ret )
|
||||||
|
ret = win->HandleWindowEvent( event );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -981,36 +1010,6 @@ gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
if (return_after_IM)
|
if (return_after_IM)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
#if wxUSE_ACCEL
|
|
||||||
if (!ret)
|
|
||||||
{
|
|
||||||
wxWindowGTK *ancestor = win;
|
|
||||||
while (ancestor)
|
|
||||||
{
|
|
||||||
int command = ancestor->GetAcceleratorTable()->GetCommand( event );
|
|
||||||
if (command != -1)
|
|
||||||
{
|
|
||||||
wxCommandEvent menu_event( wxEVT_COMMAND_MENU_SELECTED, command );
|
|
||||||
ret = ancestor->HandleWindowEvent( menu_event );
|
|
||||||
|
|
||||||
if ( !ret )
|
|
||||||
{
|
|
||||||
// if the accelerator wasn't handled as menu event, try
|
|
||||||
// it as button click (for compatibility with other
|
|
||||||
// platforms):
|
|
||||||
wxCommandEvent button_event( wxEVT_COMMAND_BUTTON_CLICKED, command );
|
|
||||||
ret = ancestor->HandleWindowEvent( button_event );
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (ancestor->IsTopLevel())
|
|
||||||
break;
|
|
||||||
ancestor = ancestor->GetParent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif // wxUSE_ACCEL
|
|
||||||
|
|
||||||
// Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
|
// Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
|
||||||
// will only be sent if it is not in an accelerator table.
|
// will only be sent if it is not in an accelerator table.
|
||||||
if (!ret)
|
if (!ret)
|
||||||
|
Reference in New Issue
Block a user