1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00

Prevent keyboard navigation from being blocked on Mac

Readonly or non-editable text controls block keyboard navigation
on the Mac, so make them normal text controls, but block any edits.
This commit is contained in:
Leland Lucius
2021-04-01 20:01:39 -05:00
parent 7a55c90b9d
commit e47f27b106
4 changed files with 48 additions and 41 deletions

View File

@@ -36,6 +36,7 @@
#include "../ShuttleGui.h" #include "../ShuttleGui.h"
#include "../TempDirectory.h" #include "../TempDirectory.h"
#include "../widgets/AudacityMessageBox.h" #include "../widgets/AudacityMessageBox.h"
#include "../widgets/wxTextCtrlWrapper.h"
using namespace FileNames; using namespace FileNames;
using namespace TempDirectory; using namespace TempDirectory;
@@ -245,9 +246,9 @@ void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S)
S.Id(TempButtonID).AddButton(XXO("Brow&se...")); S.Id(TempButtonID).AddButton(XXO("Brow&se..."));
S.AddPrompt(XXO("&Free Space:")); S.AddPrompt(XXO("&Free Space:"));
mFreeSpace = S.Style(wxTE_READONLY).AddTextBox({}, wxT(""), 30); mFreeSpace = S.AddTextBox({}, wxT(""), 30);
if( mFreeSpace )
mFreeSpace->SetName(XO("Free Space").Translation()); mFreeSpace->SetName(XO("Free Space").Translation());
((wxTextCtrlWrapper *) mFreeSpace)->SetReadOnly();
} }
S.EndMultiColumn(); S.EndMultiColumn();
} }

View File

@@ -29,6 +29,7 @@ MP3 and FFmpeg encoding libraries.
#include "../export/ExportMP3.h" #include "../export/ExportMP3.h"
#include "../widgets/HelpSystem.h" #include "../widgets/HelpSystem.h"
#include "../widgets/AudacityMessageBox.h" #include "../widgets/AudacityMessageBox.h"
#include "../widgets/wxTextCtrlWrapper.h"
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -101,32 +102,9 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartTwoColumn(); S.StartTwoColumn();
{ {
S.AddVariableText(XO("MP3 Library Version:"), mMP3Version = S
true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL); .AddTextBox(XO("MP3 Library Version:"), "", 50);
// Change this text later: ((wxTextCtrlWrapper *) mMP3Version)->SetReadOnly();
mMP3Version = S.AddVariableText(Verbatim("9.99"),
true, wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
// Old buttons, not needed now that the lib is built-in.
#ifndef MP3_EXPORT_BUILT_IN
S.AddVariableText(XO("LAME MP3 Library:"),
true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
S.Id(ID_MP3_FIND_BUTTON)
#ifdef DISABLE_DYNAMIC_LOADING_LAME
.Disable()
#endif
.AddButton(XXO("&Locate..."),
wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
S.AddVariableText(XO("LAME MP3 Library:"),
true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
S.Id(ID_MP3_DOWN_BUTTON)
#ifdef DISABLE_DYNAMIC_LOADING_LAME
.Disable()
#endif
.AddButton(XXO("&Download"),
wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
#endif
} }
S.EndTwoColumn(); S.EndTwoColumn();
} }
@@ -136,17 +114,17 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
{ {
S.StartTwoColumn(); S.StartTwoColumn();
{ {
S.AddVariableText(XO("FFmpeg Library Version:"), auto version =
true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
#if defined(USE_FFMPEG) #if defined(USE_FFMPEG)
mFFmpegVersion = S.AddVariableText( XO("No compatible FFmpeg library was found");
XO("No compatible FFmpeg library was found"),
true, wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
#else #else
mFFmpegVersion = S.AddVariableText( XO("FFmpeg support is not compiled in");
XO("FFmpeg support is not compiled in"),
true, wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
#endif #endif
mFFmpegVersion = S
.AddTextBox(XO("FFmpeg Library Version:"), version.Translation(), 50);
((wxTextCtrlWrapper *) mFFmpegVersion)->SetReadOnly();
S.AddVariableText(XO("FFmpeg Library:"), S.AddVariableText(XO("FFmpeg Library:"),
true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL); true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
S.Id(ID_FFMPEG_FIND_BUTTON); S.Id(ID_FFMPEG_FIND_BUTTON);
@@ -177,7 +155,7 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
/// of the MP3 Library version. /// of the MP3 Library version.
void LibraryPrefs::SetMP3VersionText(bool prompt) void LibraryPrefs::SetMP3VersionText(bool prompt)
{ {
mMP3Version->SetLabel(GetMP3Version(this, prompt).Translation()); mMP3Version->SetValue(GetMP3Version(this, prompt).Translation());
mMP3Version->SetName(mMP3Version->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) mMP3Version->SetName(mMP3Version->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
} }
@@ -197,7 +175,7 @@ void LibraryPrefs::OnMP3DownButton(wxCommandEvent & WXUNUSED(event))
void LibraryPrefs::SetFFmpegVersionText() void LibraryPrefs::SetFFmpegVersionText()
{ {
mFFmpegVersion->SetLabel(GetFFmpegVersion().Translation()); mFFmpegVersion->SetValue(GetFFmpegVersion().Translation());
mFFmpegVersion->SetName(mFFmpegVersion->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs) mFFmpegVersion->SetName(mFFmpegVersion->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
} }

View File

@@ -18,6 +18,7 @@
#include "PrefsPanel.h" #include "PrefsPanel.h"
class wxStaticText; class wxStaticText;
class wxTextCtrl;
class ShuttleGui; class ShuttleGui;
#define LIBRARY_PREFS_PLUGIN_SYMBOL ComponentInterfaceSymbol{ XO("Library") } #define LIBRARY_PREFS_PLUGIN_SYMBOL ComponentInterfaceSymbol{ XO("Library") }
@@ -44,8 +45,8 @@ class LibraryPrefs final : public PrefsPanel
void OnFFmpegFindButton(wxCommandEvent & e); void OnFFmpegFindButton(wxCommandEvent & e);
void OnFFmpegDownButton(wxCommandEvent & e); void OnFFmpegDownButton(wxCommandEvent & e);
wxStaticText *mMP3Version; wxTextCtrl *mMP3Version;
wxStaticText *mFFmpegVersion; wxTextCtrl *mFFmpegVersion;
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@@ -31,6 +31,20 @@ public:
const wxString &name = wxTextCtrlNameStr) const wxString &name = wxTextCtrlNameStr)
: wxTextCtrl(parent, id, value, pos, size, style, validator, name) : wxTextCtrl(parent, id, value, pos, size, style, validator, name)
{ {
mReadOnly = false;
Bind(wxEVT_CHAR, [&](wxKeyEvent &event)
{
auto keyCode = event.GetUnicodeKey();
if (!mReadOnly || keyCode < WXK_SPACE || keyCode == WXK_DELETE)
{
event.Skip();
}
else
{
event.Skip(false);
}
});
}; };
~wxTextCtrlWrapper() ~wxTextCtrlWrapper()
@@ -41,6 +55,19 @@ public:
{ {
return true; return true;
} }
bool IsReadOnly()
{
return mReadOnly;
}
void SetReadOnly(bool readonly = true)
{
mReadOnly = readonly;
}
private:
bool mReadOnly;
}; };
#endif // __AUDACITY_WXTEXTCTRLWRAPPER__ #endif // __AUDACITY_WXTEXTCTRLWRAPPER__