diff --git a/src/Project.cpp b/src/Project.cpp index 466041e7c..35b0fbea8 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -1879,6 +1879,9 @@ bool AudacityProject::HandleKeyDown(wxKeyEvent & event) if (wxGetTopLevelParent(wxWindow::FindFocus()) != this) return false; + if (event.GetKeyCode() == WXK_ESCAPE) + mTrackPanel->HandleEscapeKey(true); + if (event.GetKeyCode() == WXK_ALT) mTrackPanel->HandleAltKey(true); @@ -1925,6 +1928,9 @@ bool AudacityProject::HandleKeyUp(wxKeyEvent & event) if (wxGetTopLevelParent(wxWindow::FindFocus()) != this) return false; + if (event.GetKeyCode() == WXK_ESCAPE) + mTrackPanel->HandleEscapeKey(false); + if (event.GetKeyCode() == WXK_ALT) mTrackPanel->HandleAltKey(false); diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 0f70d8072..6f1f401dd 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -1565,8 +1565,11 @@ void TrackPanel::MakeParentResize() mListener->TP_HandleResize(); } -void TrackPanel::HandleEscapeKey() +void TrackPanel::HandleEscapeKey(bool down) { + if (!down) + return; + switch (mMouseCapture) { case IsSelecting: @@ -6335,60 +6338,6 @@ void TrackPanel::OnKeyDown(wxKeyEvent & event) { Track *t = GetFocusedTrack(); - if (event.GetKeyCode() == WXK_ESCAPE) { - HandleEscapeKey(); - return; - } - -#ifdef EXPERIMENTAL_SPECTRAL_EDITING -#ifdef SPECTRAL_EDITING_ESC_KEY - // Test for pinning and unpinning of the center frequency - bool logF; - if (mAdjustSelectionEdges && - event.GetKeyCode() == WXK_ESCAPE) { - if (mFreqSelMode == FREQ_SEL_SNAPPING_CENTER) { - // Toggle center snapping off - // (left click can also turn it off) - mFreqSelMode = FREQ_SEL_INVALID; - } - else if (isSpectrogramTrack(t, &logF)) { - WaveTrack *wt = static_cast(t); - if (mFreqSelMode == FREQ_SEL_INVALID) { - // Toggle center snapping on (the only way to do this) - mFreqSelMode = FREQ_SEL_SNAPPING_CENTER; - StartSnappingFreqSelection(wt); - } - else { - // Handle ESC during frequency drag - wxMouseState state(::wxGetMouseState()); - wxCoord yy = state.GetY(); - ScreenToClient(NULL, &yy); - wxRect r; - if (wt == FindTrack(state.GetX(), yy, false, false, &r)) { - eFreqSelMode saveMode = mFreqSelMode; - mFreqSelMode = FREQ_SEL_PINNED_CENTER; - - StartSnappingFreqSelection(wt); - MoveSnappingFreqSelection(yy, r.y, r.height, wt); - ExtendFreqSelection(yy, r.y, r.height); - UpdateSelectionDisplay(); - - mFreqSelMode = saveMode; - double hint = -1.0; - if (mFreqSelMode == FREQ_SEL_FREE) { - hint = PositionToFrequency - (true, yy, r.y, r.height, wt->GetRate(), logF); - } - ResetFreqSelectionPin(hint, logF); - // MakeParentModifyState(false); - } - } - // And don't skip event, yet - } - } -#endif -#endif - // Only deal with LabelTracks if (!t || t->GetKind() != Track::Label) { event.Skip(); diff --git a/src/TrackPanel.h b/src/TrackPanel.h index 41b951cb1..07631921d 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -182,7 +182,7 @@ class AUDACITY_DLL_API TrackPanel:public wxPanel { //virtual void SetSelectionFormat(int iformat) //virtual void SetSnapTo(int snapto) - void HandleEscapeKey(); + virtual void HandleEscapeKey(bool down); virtual void HandleAltKey(bool down); virtual void HandleShiftKey(bool down); virtual void HandleControlKey(bool down);