1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-01-13 16:15:48 +01:00

Fix some of the accessibility names that disappeared with the move to WX 3.1.1

The main change in wxWidgets for the setting of accessibility names is:
7dab555f71 (diff-04f5191d86f95b1c4d5d9c979da65878)

Before this change, with wxUSE_ACCESSIBILITY set to 1, for wxWindow and all the classes derived from it, wxWidgets automatically created accessible objects to handle accessibility itself. Because the way wxWindowAccessible::GetName() was written, the accessibility names of lots of windows and controls had to be set using SetName().

After the change, by default, the accessibility of instances of these classes is handled by Windows. Where the accessibility of a control is handled by Windows, then the accessibility name is automatically set to so the appropriate value. However, an accessible can still be set using SetAccessible() then wxWidgets handles the accessibility for this object.

So for many controls we can just leave Windows to set the accessibility name. However, for controls which don't have any visible labels, or where we want to accessibility name to different from the visible text, then we have to set an accessible object for that control, and then call SetName(). The Class WindowAccessible can be used for this purpose. And for custom widgets, like the TrackPanel, and the NumericTextCtrl, SetAccessible() still has to be called, since they need bespoke accessible objects

So in the cases where we want the accessible name to be different from normal, we now need to explicitly set an accessible object. (Before, this wasn't needed, as accessible objects were automatically created.).

Some notes of the fixes included in this commit:
1. The fixes cover the main window, preferences, and built-in effects. Other fixes will follow.

2. In ShuttleGui, I've set accessible objects for wxTextCtrls and wxSliders. So all of these widgets still need the name set. This was done because there are a lot of instances where these controls need non standard accessibility names, and so it saves having to put lots of SetAccessibles throughout the code.

3. For wxPanel, Windows picks up the accessibility name from the label, and so SetLabel() can be used instead of SetName(). This is just as well, since for windows that contain other windows or controls, setting WindowAccessible as the accessibility object breaks the accessibility tree.

Note that at some stage a lot of calls to SetName() can be removed from the code as they are no longer needed, but it might be better to leave them there for the moment, just in case they are unexpectedly needed.
This commit is contained in:
David Bailes
2018-04-05 10:57:12 +01:00
parent 6e59c2e286
commit f9ee3cdc45
7 changed files with 106 additions and 4 deletions

View File

@@ -45,6 +45,10 @@
#include "../DeviceManager.h"
#include "../widgets/ErrorDialog.h"
#if wxUSE_ACCESSIBILITY
#include "../widgets/WindowAccessible.h"
#endif
IMPLEMENT_CLASS(DeviceToolBar, ToolBar);
////////////////////////////////////////////////////////////
@@ -93,7 +97,10 @@ void DeviceToolBar::Populate()
wxID_ANY,
wxDefaultPosition,
wxDefaultSize);
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
mHost->SetAccessible(safenew WindowAccessible(mHost));
#endif
Add(mHost, 0, wxALIGN_CENTER);
// Input device
@@ -104,12 +111,20 @@ void DeviceToolBar::Populate()
wxID_ANY,
wxDefaultPosition,
wxDefaultSize);
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
mInput->SetAccessible(safenew WindowAccessible(mInput));
#endif
// Input channels
Add(mInput, 0, wxALIGN_CENTER);
mInputChannels = safenew wxChoice(this,
wxID_ANY,
wxDefaultPosition,
wxDefaultSize);
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
mInputChannels->SetAccessible(safenew WindowAccessible(mInputChannels));
#endif
Add(mInputChannels, 0, wxALIGN_CENTER);
// Output device
@@ -120,6 +135,10 @@ void DeviceToolBar::Populate()
wxID_ANY,
wxDefaultPosition,
wxDefaultSize);
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
mOutput->SetAccessible(safenew WindowAccessible(mOutput));
#endif
Add(mOutput, 0, wxALIGN_CENTER);

View File

@@ -57,6 +57,10 @@ with changes in the SelectionBar.
#include "../widgets/NumericTextCtrl.h"
#include "../AllThemeResources.h"
#if wxUSE_ACCESSIBILITY
#include "../widgets/WindowAccessible.h"
#endif
IMPLEMENT_CLASS(SelectionBar, ToolBar);
const static wxChar *numbers[] =
@@ -276,6 +280,10 @@ void SelectionBar::Populate()
(this, ChoiceID, wxDefaultPosition, wxDefaultSize, 4, choices,
0, wxDefaultValidator, _("Show"));
mChoice->SetSelection(0);
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
mChoice->SetAccessible(safenew WindowAccessible(mChoice));
#endif
#ifdef __WXGTK__
// Combo boxes are taller on Linux, and if we don't do the following, the selection toolbar will
// be three units high.
@@ -293,6 +301,10 @@ void SelectionBar::Populate()
mRateBox = safenew wxComboBox(this, RateID,
wxT(""),
wxDefaultPosition, wxSize(80, -1));
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
mRateBox->SetAccessible(safenew WindowAccessible(mRateBox));
#endif
mRateBox->SetName(_("Project Rate (Hz)"));
//mRateBox->SetForegroundColour( clrText2 );
wxTextValidator vld(wxFILTER_INCLUDE_CHAR_LIST);
@@ -352,6 +364,10 @@ void SelectionBar::Populate()
mainSizer->Add(mSnapTo,
0, wxALIGN_TOP | wxRIGHT, 5);
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
mSnapTo->SetAccessible(safenew WindowAccessible(mSnapTo));
#endif
mSnapTo->SetName(_("Snap To"));
//mSnapTo->SetForegroundColour( clrText2 );
mSnapTo->SetSelection(mListener ? mListener->AS_GetSnapTo() : SNAP_OFF);

View File

@@ -59,6 +59,10 @@ with changes in the SpectralSelectionBar.
#include "../Experimental.h"
#include "../Internat.h"
#if wxUSE_ACCESSIBILITY
#include "../widgets/WindowAccessible.h"
#endif
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
IMPLEMENT_CLASS(SpectralSelectionBar, ToolBar);
@@ -148,6 +152,10 @@ void SpectralSelectionBar::Populate()
(this, OnChoiceID, wxDefaultPosition, wxDefaultSize, 2, choices,
0, wxDefaultValidator, _("Spectral Selection"));
mChoice->SetSelection(mbCenterAndWidth ? 0 : 1);
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
mChoice->SetAccessible(safenew WindowAccessible(mChoice));
#endif
#ifdef __WXGTK__
// Combo boxes are taller on Linux, and if we don't do the following, the selection toolbar will
// be three units high.