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

Method OnKeyEvent

src/toolbars/ControlToolBar.cpp:536–565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

534}
535
536void ControlToolBar::OnKeyEvent(wxKeyEvent & event)
537{
538 // PRL: is this handler really ever reached? Is the ControlToolBar ever
539 // focused? Isn't there a global event filter that interprets the spacebar
540 // key (or other key chosen in preferences) and dispatches to DoPlayStop,
541 // according to CommandManager's table, before we come to this redundant
542 // function?
543
544 if (event.ControlDown() || event.AltDown()) {
545 event.Skip();
546 return;
547 }
548
549 auto gAudioIO = AudioIOBase::Get();
550 auto &projectAudioManager = ProjectAudioManager::Get( mProject );
551
552 // Does not appear to be needed on Linux. Perhaps on some other platform?
553 // If so, "!CanStopAudioStream()" should probably apply.
554 if (event.GetKeyCode() == WXK_SPACE) {
555 if ( projectAudioManager.Playing() || projectAudioManager.Recording() ) {
556 SetStop();
557 projectAudioManager.Stop();
558 }
559 else if (!gAudioIO->IsBusy()) {
560 projectAudioManager.PlayCurrentRegion();
561 }
562 return;
563 }
564 event.Skip();
565}
566
567void ControlToolBar::OnPlay(wxCommandEvent & WXUNUSED(evt))
568{

Callers

nothing calls this directly

Calls 7

GetFunction · 0.85
SkipMethod · 0.80
PlayingMethod · 0.80
RecordingMethod · 0.80
IsBusyMethod · 0.80
PlayCurrentRegionMethod · 0.80
StopMethod · 0.45

Tested by

no test coverage detected