Don't steal command-keys from a wxGrid.
It's unlikely to win you friends. Fixes https://gitlab.com/kicad/code/kicad/-/issues/17229
This commit is contained in:
parent
428f2087bd
commit
1082930c34
|
@ -39,6 +39,7 @@
|
||||||
#include <wx/stc/stc.h>
|
#include <wx/stc/stc.h>
|
||||||
#include <textentry_tricks.h>
|
#include <textentry_tricks.h>
|
||||||
#include <wx/listctrl.h>
|
#include <wx/listctrl.h>
|
||||||
|
#include <wx/grid.h>
|
||||||
#include <widgets/ui_common.h>
|
#include <widgets/ui_common.h>
|
||||||
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
@ -436,7 +437,8 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent )
|
||||||
// events first.
|
// events first.
|
||||||
if( dynamic_cast<wxTextEntry*>( focus )
|
if( dynamic_cast<wxTextEntry*>( focus )
|
||||||
|| dynamic_cast<wxStyledTextCtrl*>( focus )
|
|| dynamic_cast<wxStyledTextCtrl*>( focus )
|
||||||
|| dynamic_cast<wxListView*>( focus ) )
|
|| dynamic_cast<wxListView*>( focus )
|
||||||
|
|| dynamic_cast<wxGrid*>( focus ) )
|
||||||
{
|
{
|
||||||
// Original key event has been lost, so we have to re-create it from the menu's
|
// Original key event has been lost, so we have to re-create it from the menu's
|
||||||
// wxAcceleratorEntry.
|
// wxAcceleratorEntry.
|
||||||
|
@ -451,7 +453,7 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent )
|
||||||
keyEvent.m_shiftDown = ( acceleratorKey->GetFlags() & wxMOD_SHIFT ) > 0;
|
keyEvent.m_shiftDown = ( acceleratorKey->GetFlags() & wxMOD_SHIFT ) > 0;
|
||||||
keyEvent.m_altDown = ( acceleratorKey->GetFlags() & wxMOD_ALT ) > 0;
|
keyEvent.m_altDown = ( acceleratorKey->GetFlags() & wxMOD_ALT ) > 0;
|
||||||
|
|
||||||
if( auto ctrl = dynamic_cast<wxTextEntry*>( focus ) )
|
if( wxTextEntry* ctrl = dynamic_cast<wxTextEntry*>( focus ) )
|
||||||
TEXTENTRY_TRICKS::OnCharHook( ctrl, keyEvent );
|
TEXTENTRY_TRICKS::OnCharHook( ctrl, keyEvent );
|
||||||
else
|
else
|
||||||
focus->HandleWindowEvent( keyEvent );
|
focus->HandleWindowEvent( keyEvent );
|
||||||
|
@ -462,10 +464,14 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent )
|
||||||
focus->HandleWindowEvent( keyEvent );
|
focus->HandleWindowEvent( keyEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the event was used as KEY event (not skipped) by the focused window,
|
// Don't bubble-up dangerous actions; the target may be behind a modeless dialog.
|
||||||
// just finish.
|
// Cf. https://gitlab.com/kicad/code/kicad/-/issues/17229
|
||||||
// Otherwise this is actually a wxEVT_COMMAND_MENU_SELECTED, or the
|
if( keyEvent.GetKeyCode() == WXK_BACK || keyEvent.GetKeyCode() == WXK_DELETE )
|
||||||
// focused window is read only
|
return;
|
||||||
|
|
||||||
|
// If the event was used as a KEY event (not skipped) by the focused window,
|
||||||
|
// just finish. Otherwise this is actually a wxEVT_COMMAND_MENU_SELECTED (or the
|
||||||
|
// focused window is read only).
|
||||||
if( !keyEvent.GetSkipped() )
|
if( !keyEvent.GetSkipped() )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue