MCPcopy Create free account
hub / github.com/audacity/audacity / FilterKeyEvent

Method FilterKeyEvent

src/MenuCreator.cpp:568–678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

566}
567
568bool MenuCreator::FilterKeyEvent(
569 AudacityProject &project, const wxKeyEvent & evt, bool permit)
570{
571 auto &cm = Get(project);
572
573 auto pWindow = FindProjectFrame(&project);
574 CommandListEntry *entry = cm.mCommandKeyHash[KeyEventToKeyString(evt)];
575 if (entry == NULL)
576 {
577 return false;
578 }
579
580 int type = evt.GetEventType();
581
582 // Global commands aren't tied to any specific project
583 if (entry->isGlobal && type == wxEVT_KEY_DOWN)
584 {
585 // Global commands are always disabled so they do not interfere with the
586 // rest of the command handling. But, to use the common handler, we
587 // enable them temporarily and then disable them again after handling.
588 // LL: Why do they need to be disabled???
589 entry->enabled = false;
590 auto cleanup = valueRestorer( entry->enabled, true );
591 return cm.HandleCommandEntry(entry, NoFlagsSpecified, false, &evt);
592 }
593
594 wxWindow * pFocus = wxWindow::FindFocus();
595 wxWindow * pParent = wxGetTopLevelParent( pFocus );
596 bool validTarget = pParent == pWindow;
597 // Bug 1557. MixerBoard should count as 'destined for project'
598 // MixerBoard IS a TopLevelWindow, and its parent is the project.
599 if( pParent && pParent->GetParent() == pWindow ){
600 if(auto keystrokeHandlingWindow = dynamic_cast< TopLevelKeystrokeHandlingWindow* >( pParent ))
601 validTarget = keystrokeHandlingWindow->HandleCommandKeystrokes();
602 }
603 validTarget = validTarget && wxEventLoop::GetActive()->IsMain();
604
605 // Any other keypresses must be destined for this project window
606 if (!permit && !validTarget )
607 {
608 return false;
609 }
610
611 auto flags = cm.GetUpdateFlags();
612
613 wxKeyEvent temp = evt;
614
615 // Possibly let wxWidgets do its normal key handling IF it is one of
616 // the standard navigation keys.
617 if((type == wxEVT_KEY_DOWN) || (type == wxEVT_KEY_UP ))
618 {
619 wxWindow * pWnd = wxWindow::FindFocus();
620 bool bIntercept =
621 pWnd && !dynamic_cast< NonKeystrokeInterceptingWindow * >( pWnd );
622
623 //wxLogDebug("Focus: %p TrackPanel: %p", pWnd, pTrackPanel );
624 // We allow the keystrokes below to be handled by wxWidgets controls IF we are
625 // in some sub window rather than in the TrackPanel itself.

Callers

nothing calls this directly

Calls 10

GetFunction · 0.85
FindProjectFrameFunction · 0.85
KeyEventToKeyStringFunction · 0.85
valueRestorerFunction · 0.85
FindFocusFunction · 0.85
GetActiveFunction · 0.85
HandleCommandEntryMethod · 0.80
GetUpdateFlagsMethod · 0.80
GetParentMethod · 0.45

Tested by

no test coverage detected