Navigation Menu

Skip to content

Commit

Permalink
#5754: Add Ctrl-A to list of shortcuts. Refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Sep 12, 2021
1 parent ebe064a commit 8e1dafb
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions radiant/eventmanager/GlobalKeyEventFilter.cpp
Expand Up @@ -29,6 +29,27 @@ namespace ui

return view != nullptr ? view : dynamic_cast<wxutil::TreeView*>(window->GetParent());
}

// Checks if the key event refers to a well-knnown shortcut that
// needs to be propagated to input controls. Returns false if the shortcut should be propagated.
bool FilterInTextControls(wxKeyEvent& keyEvent)
{
if (keyEvent.ControlDown() && keyEvent.GetKeyCode() > 32 && keyEvent.GetKeyCode() < 127)
{
switch (keyEvent.GetKeyCode())
{
case 'C':case 'V':case 'X': // copy/paste
case 'Y':case 'Z': // redo/undo
case 'A': // select all
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::GlobalKeyEventFilter(EventManager& eventManager) :
Expand Down Expand Up @@ -75,21 +96,6 @@ 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

0 comments on commit 8e1dafb

Please sign in to comment.