diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index 7f90c2d91..4fe3899b5 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -3284,3 +3284,16 @@ void AdornedRulerPanel::GetMaxSize(wxCoord *width, wxCoord *height) { mRuler.GetMaxSize(width, height); } + +bool AdornedRulerPanel::s_AcceptsFocus{ false }; + +auto AdornedRulerPanel::TemporarilyAllowFocus() -> TempAllowFocus { + s_AcceptsFocus = true; + return std::move(TempAllowFocus{ &s_AcceptsFocus }); +} + +void AdornedRulerPanel::SetFocusFromKbd() +{ + auto temp = TemporarilyAllowFocus(); + SetFocus(); +} diff --git a/src/widgets/Ruler.h b/src/widgets/Ruler.h index 84dc44d46..6b1f8731e 100644 --- a/src/widgets/Ruler.h +++ b/src/widgets/Ruler.h @@ -294,8 +294,9 @@ public: ~AdornedRulerPanel(); - bool AcceptsFocus() const override { return false; } - bool AcceptsFocusFromKeyboard() const override { return false; } + bool AcceptsFocus() const override { return s_AcceptsFocus; } + bool AcceptsFocusFromKeyboard() const override { return true; } + void SetFocusFromKbd() override; public: int GetRulerHeight() { return GetRulerHeight(mShowScrubbing); } @@ -357,6 +358,14 @@ public: void DoDrawIndicator(wxDC * dc, wxCoord xx, bool playing, int width, bool scrub, bool seek); void UpdateButtonStates(); +private: + static bool s_AcceptsFocus; + struct Resetter { void operator () (bool *p) const { if(p) *p = false; } }; + using TempAllowFocus = std::unique_ptr; + +public: + static TempAllowFocus TemporarilyAllowFocus(); + private: QuickPlayIndicatorOverlay *GetOverlay(); void ShowOrHideQuickPlayIndicator(bool show);