From 4d1ce201e4354456b6422372378d7f10a2bfd6a5 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 13 Jul 2017 08:09:39 -0400 Subject: [PATCH] Make TAB key act as before, when a Label track has focus. --- src/TrackPanel.cpp | 22 ++++++++++++++-------- src/TrackPanel.h | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 3e0c5cbb0..b8f0210c4 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -1347,18 +1347,15 @@ void TrackPanel::HandleWheelRotation( TrackPanelMouseEvent &tpmEvent ) void TrackPanel::OnCaptureKey(wxCommandEvent & event) { + mEnableTab = false; wxKeyEvent *kevent = static_cast(event.GetEventObject()); const auto code = kevent->GetKeyCode(); if ( WXK_ESCAPE != code ) HandleInterruptedDrag(); - if ( WXK_TAB == code && HasRotation() ) { - // Override what the cell might do, don't call its CaptureKey; - // Also override TAB navigation in wxWidgets, by not skipping - event.Skip(false); - return; - } + // TODO? Some notion of focused cell, more generally than focused tracks + // Give focused track precedence Track * const t = GetFocusedTrack(); if (t) { const unsigned refreshResult = @@ -1366,7 +1363,16 @@ void TrackPanel::OnCaptureKey(wxCommandEvent & event) ProcessUIHandleResult(this, mRuler, t, t, refreshResult); event.Skip(kevent->GetSkipped()); } - else + + // Special TAB key handling, but only if the track didn't capture it + if ( !(t && !kevent->GetSkipped()) && + WXK_TAB == code && HasRotation() ) { + // Override TAB navigation in wxWidgets, by not skipping + event.Skip(false); + mEnableTab = true; + return; + } + else if (!t) event.Skip(); } @@ -1402,7 +1408,7 @@ void TrackPanel::OnKeyDown(wxKeyEvent & event) return; case WXK_TAB: - if ( HasRotation() ) { + if ( mEnableTab && HasRotation() ) { RotateTarget( !event.ShiftDown() ); HandleCursorForPresentMouseState(false); return; diff --git a/src/TrackPanel.h b/src/TrackPanel.h index cf7344b13..bfefabba4 100644 --- a/src/TrackPanel.h +++ b/src/TrackPanel.h @@ -558,6 +558,8 @@ protected: std::shared_ptr mpBackground; + bool mEnableTab{}; + DECLARE_EVENT_TABLE() };