1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-31 16:09:28 +02: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 "../TempDirectory.h"
#include "../widgets/AudacityMessageBox.h"
#include "../widgets/wxTextCtrlWrapper.h"
using namespace FileNames;
using namespace TempDirectory;
@ -245,9 +246,9 @@ void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S)
S.Id(TempButtonID).AddButton(XXO("Brow&se..."));
S.AddPrompt(XXO("&Free Space:"));
mFreeSpace = S.Style(wxTE_READONLY).AddTextBox({}, wxT(""), 30);
if( mFreeSpace )
mFreeSpace->SetName(XO("Free Space").Translation());
mFreeSpace = S.AddTextBox({}, wxT(""), 30);
mFreeSpace->SetName(XO("Free Space").Translation());
((wxTextCtrlWrapper *) mFreeSpace)->SetReadOnly();
}
S.EndMultiColumn();
}

View File

@ -29,6 +29,7 @@ MP3 and FFmpeg encoding libraries.
#include "../export/ExportMP3.h"
#include "../widgets/HelpSystem.h"
#include "../widgets/AudacityMessageBox.h"
#include "../widgets/wxTextCtrlWrapper.h"
////////////////////////////////////////////////////////////////////////////////
@ -101,32 +102,9 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
{
S.StartTwoColumn();
{
S.AddVariableText(XO("MP3 Library Version:"),
true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
// Change this text later:
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
mMP3Version = S
.AddTextBox(XO("MP3 Library Version:"), "", 50);
((wxTextCtrlWrapper *) mMP3Version)->SetReadOnly();
}
S.EndTwoColumn();
}
@ -136,17 +114,17 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
{
S.StartTwoColumn();
{
S.AddVariableText(XO("FFmpeg Library Version:"),
true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
auto version =
#if defined(USE_FFMPEG)
mFFmpegVersion = S.AddVariableText(
XO("No compatible FFmpeg library was found"),
true, wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
XO("No compatible FFmpeg library was found");
#else
mFFmpegVersion = S.AddVariableText(
XO("FFmpeg support is not compiled in"),
true, wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
XO("FFmpeg support is not compiled in");
#endif
mFFmpegVersion = S
.AddTextBox(XO("FFmpeg Library Version:"), version.Translation(), 50);
((wxTextCtrlWrapper *) mFFmpegVersion)->SetReadOnly();
S.AddVariableText(XO("FFmpeg Library:"),
true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
S.Id(ID_FFMPEG_FIND_BUTTON);
@ -177,7 +155,7 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
/// of the MP3 Library version.
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)
}
@ -197,7 +175,7 @@ void LibraryPrefs::OnMP3DownButton(wxCommandEvent & WXUNUSED(event))
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)
}

View File

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

View File

@ -31,6 +31,20 @@ public:
const wxString &name = wxTextCtrlNameStr)
: 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()
@ -41,6 +55,19 @@ public:
{
return true;
}
bool IsReadOnly()
{
return mReadOnly;
}
void SetReadOnly(bool readonly = true)
{
mReadOnly = readonly;
}
private:
bool mReadOnly;
};
#endif // __AUDACITY_WXTEXTCTRLWRAPPER__