From ad26c35d3ca5ead6ccc6191e1875536ae196be6c Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 30 Apr 2019 19:12:06 -0400 Subject: [PATCH] Fix Tab key navigation on Mac in presence of static boxes --- src/ShuttleGui.cpp | 4 +--- src/ShuttleGui.h | 16 ++++++++++++++++ src/import/ImportPCM.cpp | 3 ++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/ShuttleGui.cpp b/src/ShuttleGui.cpp index df8bcb533..9a210dab3 100644 --- a/src/ShuttleGui.cpp +++ b/src/ShuttleGui.cpp @@ -783,8 +783,6 @@ wxMenu * ShuttleGuiBase::AddMenu( const wxString & Title ) return mpMenu; } - - /// Starts a static box around a number of controls. /// @param Str The text of the title for the box. /// @param iProp The resizing proportion value. @@ -795,7 +793,7 @@ wxStaticBox * ShuttleGuiBase::StartStatic(const wxString &Str, int iProp) UseUpId(); if( mShuttleMode != eIsCreating ) return NULL; - wxStaticBox * pBox = safenew wxStaticBox(GetParent(), miId, + wxStaticBox * pBox = safenew wxStaticBoxWrapper(GetParent(), miId, Str ); pBox->SetLabel( Str ); pBox->SetName(wxStripMenuCodes(Str)); diff --git a/src/ShuttleGui.h b/src/ShuttleGui.h index 69e4291d5..76a5277b4 100644 --- a/src/ShuttleGui.h +++ b/src/ShuttleGui.h @@ -78,6 +78,21 @@ class Shuttle; class WrappedType; #ifdef __WXMAC__ + +#include // to inherit + +class wxStaticBoxWrapper + : public wxStaticBox // inherit to get access to m_container +{ +public: + template< typename... Args > + wxStaticBoxWrapper( Args &&...args ) + : wxStaticBox( std::forward(args)... ) + { + m_container.EnableSelfFocus(); + } +}; + /// Fix a defect in TAB key navigation to sliders, known to happen in wxWidgets /// 3.1.1 and maybe in earlier versions class wxSliderWrapper : public wxSlider @@ -87,6 +102,7 @@ public: void SetFocus() override; }; #else +using wxStaticBoxWrapper = wxStaticBox; using wxSliderWrapper = wxSlider; #endif diff --git a/src/import/ImportPCM.cpp b/src/import/ImportPCM.cpp index 7b85213a4..039201338 100644 --- a/src/import/ImportPCM.cpp +++ b/src/import/ImportPCM.cpp @@ -52,6 +52,7 @@ #include "../FileFormats.h" #include "../Prefs.h" +#include "../ShuttleGui.h" #include "../WaveTrack.h" #include "ImportPlugin.h" @@ -278,7 +279,7 @@ static wxString AskCopyOrEdit() vbox->Add(message, 1, wxALL | wxEXPAND, 10); - wxStaticBox *box = safenew wxStaticBox(&dialog, -1, _("Choose an import method")); + wxStaticBox *box = safenew wxStaticBoxWrapper(&dialog, -1, _("Choose an import method")); box->SetName(box->GetLabel()); wxRadioButton *aliasRadio;