mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 17:09:26 +02:00
Bug 2211 - Mac: keyboard navigation problem in Libraries preferences dialog
This commit is contained in:
parent
d01776be5a
commit
6450495426
@ -942,6 +942,7 @@ list( APPEND SOURCES
|
|||||||
widgets/PopupMenuTable.h
|
widgets/PopupMenuTable.h
|
||||||
widgets/ProgressDialog.cpp
|
widgets/ProgressDialog.cpp
|
||||||
widgets/ProgressDialog.h
|
widgets/ProgressDialog.h
|
||||||
|
widgets/ReadOnlyText.h
|
||||||
widgets/Ruler.cpp
|
widgets/Ruler.cpp
|
||||||
widgets/Ruler.h
|
widgets/Ruler.h
|
||||||
widgets/Warning.cpp
|
widgets/Warning.cpp
|
||||||
|
@ -114,6 +114,7 @@ for registering for changes.
|
|||||||
#include <wx/stattext.h>
|
#include <wx/stattext.h>
|
||||||
#include <wx/bmpbuttn.h>
|
#include <wx/bmpbuttn.h>
|
||||||
#include "../include/audacity/ComponentInterface.h"
|
#include "../include/audacity/ComponentInterface.h"
|
||||||
|
#include "widgets/ReadOnlyText.h"
|
||||||
#include "widgets/wxPanelWrapper.h"
|
#include "widgets/wxPanelWrapper.h"
|
||||||
#include "widgets/wxTextCtrlWrapper.h"
|
#include "widgets/wxTextCtrlWrapper.h"
|
||||||
#include "AllThemeResources.h"
|
#include "AllThemeResources.h"
|
||||||
@ -485,6 +486,27 @@ wxStaticText * ShuttleGuiBase::AddVariableText(
|
|||||||
return pStatic;
|
return pStatic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReadOnlyText * ShuttleGuiBase::AddReadOnlyText(
|
||||||
|
const TranslatableString &Caption, const wxString &Value)
|
||||||
|
{
|
||||||
|
const auto translated = Caption.Translation();
|
||||||
|
auto style = GetStyle( wxBORDER_NONE );
|
||||||
|
HandleOptionality( Caption );
|
||||||
|
mItem.miStyle = wxALIGN_CENTER_VERTICAL;
|
||||||
|
AddPrompt( Caption );
|
||||||
|
UseUpId();
|
||||||
|
if( mShuttleMode != eIsCreating )
|
||||||
|
return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), ReadOnlyText);
|
||||||
|
ReadOnlyText * pReadOnlyText;
|
||||||
|
miProp=0;
|
||||||
|
|
||||||
|
mpWind = pReadOnlyText = safenew ReadOnlyText(GetParent(), miId, Value,
|
||||||
|
wxDefaultPosition, wxDefaultSize, GetStyle( style ));
|
||||||
|
mpWind->SetName(wxStripMenuCodes(translated));
|
||||||
|
UpdateSizers();
|
||||||
|
return pReadOnlyText;
|
||||||
|
}
|
||||||
|
|
||||||
wxComboBox * ShuttleGuiBase::AddCombo(
|
wxComboBox * ShuttleGuiBase::AddCombo(
|
||||||
const TranslatableString &Prompt,
|
const TranslatableString &Prompt,
|
||||||
const wxString &Selected, const wxArrayStringEx & choices )
|
const wxString &Selected, const wxArrayStringEx & choices )
|
||||||
|
@ -70,6 +70,7 @@ class wxSpinCtrl;
|
|||||||
class wxListBox;
|
class wxListBox;
|
||||||
class wxGrid;
|
class wxGrid;
|
||||||
class Shuttle;
|
class Shuttle;
|
||||||
|
class ReadOnlyText;
|
||||||
|
|
||||||
class WrappedType;
|
class WrappedType;
|
||||||
|
|
||||||
@ -300,6 +301,9 @@ public:
|
|||||||
wxStaticText * AddVariableText(
|
wxStaticText * AddVariableText(
|
||||||
const TranslatableString &Str, bool bCenter = false,
|
const TranslatableString &Str, bool bCenter = false,
|
||||||
int PositionFlags = 0, int wrapWidth = 0);
|
int PositionFlags = 0, int wrapWidth = 0);
|
||||||
|
ReadOnlyText * AddReadOnlyText(
|
||||||
|
const TranslatableString &Caption,
|
||||||
|
const wxString &Value);
|
||||||
wxTextCtrl * AddTextBox(
|
wxTextCtrl * AddTextBox(
|
||||||
const TranslatableString &Caption,
|
const TranslatableString &Caption,
|
||||||
const wxString &Value, const int nChars);
|
const wxString &Value, const int nChars);
|
||||||
|
@ -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/ReadOnlyText.h"
|
||||||
#include "../widgets/wxTextCtrlWrapper.h"
|
#include "../widgets/wxTextCtrlWrapper.h"
|
||||||
|
|
||||||
using namespace FileNames;
|
using namespace FileNames;
|
||||||
@ -245,10 +246,8 @@ void DirectoriesPrefs::PopulateOrExchange(ShuttleGui &S)
|
|||||||
mTempText->SetValidator(FilesystemValidator(XO("Temporary files directory cannot be on a FAT drive.")));
|
mTempText->SetValidator(FilesystemValidator(XO("Temporary files directory cannot be on a FAT drive.")));
|
||||||
S.Id(TempButtonID).AddButton(XXO("Brow&se..."));
|
S.Id(TempButtonID).AddButton(XXO("Brow&se..."));
|
||||||
|
|
||||||
S.AddPrompt(XXO("&Free Space:"));
|
mFreeSpace = S
|
||||||
mFreeSpace = S.AddTextBox({}, wxT(""), 30);
|
.AddReadOnlyText(XXO("&Free Space:"), "");
|
||||||
mFreeSpace->SetName(XO("Free Space").Translation());
|
|
||||||
((wxTextCtrlWrapper *) mFreeSpace)->SetReadOnly();
|
|
||||||
}
|
}
|
||||||
S.EndMultiColumn();
|
S.EndMultiColumn();
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "PrefsPanel.h"
|
#include "PrefsPanel.h"
|
||||||
|
|
||||||
|
class ReadOnlyText;
|
||||||
class ShuttleGui;
|
class ShuttleGui;
|
||||||
|
|
||||||
class wxStaticText;
|
class wxStaticText;
|
||||||
@ -42,7 +43,7 @@ class DirectoriesPrefs final : public PrefsPanel
|
|||||||
void OnBrowse(wxCommandEvent &evt);
|
void OnBrowse(wxCommandEvent &evt);
|
||||||
void OnText(wxCommandEvent &evt);
|
void OnText(wxCommandEvent &evt);
|
||||||
|
|
||||||
wxTextCtrl *mFreeSpace;
|
ReadOnlyText *mFreeSpace;
|
||||||
wxTextCtrl *mTempText;
|
wxTextCtrl *mTempText;
|
||||||
wxTextCtrl *mOpenText;
|
wxTextCtrl *mOpenText;
|
||||||
wxTextCtrl *mSaveText;
|
wxTextCtrl *mSaveText;
|
||||||
|
@ -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/ReadOnlyText.h"
|
||||||
#include "../widgets/wxTextCtrlWrapper.h"
|
#include "../widgets/wxTextCtrlWrapper.h"
|
||||||
|
|
||||||
|
|
||||||
@ -103,8 +104,8 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
S.StartTwoColumn();
|
S.StartTwoColumn();
|
||||||
{
|
{
|
||||||
mMP3Version = S
|
mMP3Version = S
|
||||||
.AddTextBox(XO("MP3 Library Version:"), "", 50);
|
.Position(wxALIGN_CENTRE_VERTICAL)
|
||||||
((wxTextCtrlWrapper *) mMP3Version)->SetReadOnly();
|
.AddReadOnlyText(XO("MP3 Library Version:"), "");
|
||||||
}
|
}
|
||||||
S.EndTwoColumn();
|
S.EndTwoColumn();
|
||||||
}
|
}
|
||||||
@ -122,8 +123,8 @@ void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
mFFmpegVersion = S
|
mFFmpegVersion = S
|
||||||
.AddTextBox(XO("FFmpeg Library Version:"), version.Translation(), 50);
|
.Position(wxALIGN_CENTRE_VERTICAL)
|
||||||
((wxTextCtrlWrapper *) mFFmpegVersion)->SetReadOnly();
|
.AddReadOnlyText(XO("FFmpeg Library Version:"), version.Translation());
|
||||||
|
|
||||||
S.AddVariableText(XO("FFmpeg Library:"),
|
S.AddVariableText(XO("FFmpeg Library:"),
|
||||||
true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
|
true, wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
|
||||||
@ -155,8 +156,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->SetValue(GetMP3Version(this, prompt).Translation());
|
mMP3Version->SetValue(GetMP3Version(this, prompt));
|
||||||
mMP3Version->SetName(mMP3Version->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Opens a file-finder dialog so that the user can
|
/// Opens a file-finder dialog so that the user can
|
||||||
@ -175,8 +175,7 @@ void LibraryPrefs::OnMP3DownButton(wxCommandEvent & WXUNUSED(event))
|
|||||||
|
|
||||||
void LibraryPrefs::SetFFmpegVersionText()
|
void LibraryPrefs::SetFFmpegVersionText()
|
||||||
{
|
{
|
||||||
mFFmpegVersion->SetValue(GetFFmpegVersion().Translation());
|
mFFmpegVersion->SetValue(GetFFmpegVersion());
|
||||||
mFFmpegVersion->SetName(mFFmpegVersion->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LibraryPrefs::OnFFmpegFindButton(wxCommandEvent & WXUNUSED(event))
|
void LibraryPrefs::OnFFmpegFindButton(wxCommandEvent & WXUNUSED(event))
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
class wxStaticText;
|
class wxStaticText;
|
||||||
class wxTextCtrl;
|
class wxTextCtrl;
|
||||||
|
class ReadOnlyText;
|
||||||
class ShuttleGui;
|
class ShuttleGui;
|
||||||
|
|
||||||
#define LIBRARY_PREFS_PLUGIN_SYMBOL ComponentInterfaceSymbol{ XO("Library") }
|
#define LIBRARY_PREFS_PLUGIN_SYMBOL ComponentInterfaceSymbol{ XO("Library") }
|
||||||
@ -45,8 +46,8 @@ class LibraryPrefs final : public PrefsPanel
|
|||||||
void OnFFmpegFindButton(wxCommandEvent & e);
|
void OnFFmpegFindButton(wxCommandEvent & e);
|
||||||
void OnFFmpegDownButton(wxCommandEvent & e);
|
void OnFFmpegDownButton(wxCommandEvent & e);
|
||||||
|
|
||||||
wxTextCtrl *mMP3Version;
|
ReadOnlyText *mMP3Version;
|
||||||
wxTextCtrl *mFFmpegVersion;
|
ReadOnlyText *mFFmpegVersion;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
134
src/widgets/ReadOnlyText.h
Normal file
134
src/widgets/ReadOnlyText.h
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
/**********************************************************************
|
||||||
|
|
||||||
|
Audacity: A Digital Audio Editor
|
||||||
|
|
||||||
|
ReadOnlyText.h
|
||||||
|
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
#ifndef __AUDACITY_READONLYTEXT__
|
||||||
|
#define __AUDACITY_READONLYTEXT__
|
||||||
|
|
||||||
|
#include "../Audacity.h"
|
||||||
|
|
||||||
|
#include "WindowAccessible.h"
|
||||||
|
|
||||||
|
#if wxUSE_ACCESSIBILITY
|
||||||
|
|
||||||
|
class ReadOnlyTextAx final : public WindowAccessible
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ReadOnlyTextAx(wxWindow * window)
|
||||||
|
: WindowAccessible(window)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
~ReadOnlyTextAx()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
wxAccStatus GetRole(int childId, wxAccRole *role)
|
||||||
|
{
|
||||||
|
*role = wxROLE_SYSTEM_STATICTEXT;
|
||||||
|
|
||||||
|
return wxACC_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxAccStatus GetState(int childId, long *state)
|
||||||
|
{
|
||||||
|
auto w = GetWindow();
|
||||||
|
*state = wxACC_STATE_SYSTEM_FOCUSABLE | wxACC_STATE_SYSTEM_READONLY;
|
||||||
|
*state |= ( w == wxWindow::FindFocus() ? wxACC_STATE_SYSTEM_FOCUSED : 0 );
|
||||||
|
|
||||||
|
return wxACC_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxAccStatus GetValue(int childId, wxString* strValue)
|
||||||
|
{
|
||||||
|
*strValue = GetWindow()->GetLabel();
|
||||||
|
|
||||||
|
return wxACC_OK;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class ReadOnlyText final : public wxControl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ReadOnlyText(wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxString &value,
|
||||||
|
const wxPoint &pos = wxDefaultPosition,
|
||||||
|
const wxSize &size = wxDefaultSize,
|
||||||
|
long style = wxBORDER_NONE)
|
||||||
|
: wxControl(parent, id, pos, size, style)
|
||||||
|
{
|
||||||
|
#if wxUSE_ACCESSIBILITY
|
||||||
|
SetAccessible(safenew ReadOnlyTextAx(this));
|
||||||
|
#endif
|
||||||
|
SetInitialSize(size);
|
||||||
|
|
||||||
|
Bind(wxEVT_SET_FOCUS, [&](wxFocusEvent &event)
|
||||||
|
{
|
||||||
|
SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
|
||||||
|
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT));
|
||||||
|
Refresh();
|
||||||
|
event.Skip();
|
||||||
|
});
|
||||||
|
|
||||||
|
Bind(wxEVT_KILL_FOCUS, [&](wxFocusEvent &event)
|
||||||
|
{
|
||||||
|
SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT));
|
||||||
|
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
|
||||||
|
Refresh();
|
||||||
|
event.Skip();
|
||||||
|
});
|
||||||
|
|
||||||
|
Bind(wxEVT_PAINT, [&](wxPaintEvent & WXUNUSED(event))
|
||||||
|
{
|
||||||
|
wxPaintDC dc(this);
|
||||||
|
|
||||||
|
wxRect rect = GetClientRect();
|
||||||
|
if (!IsEnabled())
|
||||||
|
{
|
||||||
|
// draw shadow of the text
|
||||||
|
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT));
|
||||||
|
wxRect rectShadow = rect;
|
||||||
|
rectShadow.Offset(1, 1);
|
||||||
|
dc.DrawLabel(GetLabel(), rectShadow, GetAlignment());
|
||||||
|
dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW));
|
||||||
|
}
|
||||||
|
dc.DrawLabel(GetLabel(), rect, GetAlignment());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
~ReadOnlyText()
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
wxSize DoGetBestClientSize() const override
|
||||||
|
{
|
||||||
|
wxClientDC dc(wxConstCast(this, ReadOnlyText));
|
||||||
|
|
||||||
|
return dc.GetMultiLineTextExtent(GetLabel());
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString GetValue()
|
||||||
|
{
|
||||||
|
return GetLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetValue(const wxString &value)
|
||||||
|
{
|
||||||
|
SetLabel(value);
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetValue(const TranslatableString &value)
|
||||||
|
{
|
||||||
|
SetValue(value.Translation());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // __AUDACITY_READONLYTEXT__
|
Loading…
x
Reference in New Issue
Block a user