Skip to content

Commit

Permalink
Simple filter to allow some menu shortcuts when focus is on a text input
Browse files Browse the repository at this point in the history
  • Loading branch information
duzenko committed Sep 11, 2021
1 parent 8b12f67 commit 2b07584
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions radiant/eventmanager/GlobalKeyEventFilter.cpp
Expand Up @@ -75,6 +75,21 @@ int GlobalKeyEventFilter::FilterEvent(wxEvent& event)
return Event_Skip;
}

bool FilterInTextControls( wxKeyEvent& keyEvent ) {
if ( keyEvent.ControlDown() ) {
if ( keyEvent.GetKeyCode() > 32 && keyEvent.GetKeyCode() < 127 ) {
switch ( keyEvent.GetKeyCode() ) {
case 'C':case 'V':case 'X':case 'Y':case 'Z':
return false;
default:
return true;
}
}
}
// For tool windows we let the ESC key propagate, since it's used to de-select stuff.
return keyEvent.GetKeyCode() == WXK_ESCAPE;
}

GlobalKeyEventFilter::EventCheckResult GlobalKeyEventFilter::checkEvent(wxKeyEvent& keyEvent)
{
// Check if the event object can handle the event
Expand Down Expand Up @@ -103,9 +118,7 @@ GlobalKeyEventFilter::EventCheckResult GlobalKeyEventFilter::checkEvent(wxKeyEve
wxDynamicCast(eventObject, wxComboBox) || wxDynamicCast(eventObject, wxSpinCtrl) ||
wxDynamicCast(eventObject, wxSpinCtrlDouble))
{
// For tool windows we let the ESC key propagate, since it's used to
// de-select stuff.
return keyEvent.GetKeyCode() == WXK_ESCAPE ? EventShouldBeProcessed : EventShouldBeIgnored;
return FilterInTextControls(keyEvent) ? EventShouldBeProcessed : EventShouldBeIgnored;
}

// Special handling for our treeviews with type ahead search
Expand Down

0 comments on commit 2b07584

Please sign in to comment.