1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-25 15:53:52 +02: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

@@ -43,6 +43,10 @@ KeyConfigPrefs and MousePrefs use.
#include "../widgets/KeyView.h"
#include "../widgets/ErrorDialog.h"
#if wxUSE_ACCESSIBILITY
#include "../widgets/WindowAccessible.h"
#endif
//
// KeyConfigPrefs
//
@@ -159,6 +163,12 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S)
if( mViewByName ) mViewByName->SetName(_("View by name"));
mViewByKey = S.Id(ViewByKeyID).TieRadioButton(_("&Key"), wxT("key"));
if( mViewByKey ) mViewByKey->SetName(_("View by key"));
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
mViewByTree->SetAccessible(safenew WindowAccessible(mViewByTree));
mViewByName->SetAccessible(safenew WindowAccessible(mViewByName));
mViewByKey->SetAccessible(safenew WindowAccessible(mViewByKey));
#endif
}
S.EndRadioButtonGroup();
}
@@ -224,7 +234,10 @@ void KeyConfigPrefs::PopulateOrExchange(ShuttleGui & S)
wxSize(210, -1),
#endif
wxTE_PROCESS_ENTER);
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
mKey->SetAccessible(safenew WindowAccessible(mKey));
#endif
mKey->SetName(_("Short cut"));
mKey->Bind(wxEVT_KEY_DOWN,
&KeyConfigPrefs::OnHotkeyKeyDown,

View File

@@ -71,6 +71,10 @@
#include "../Theme.h"
#include "../widgets/HelpSystem.h"
#if wxUSE_ACCESSIBILITY
#include "../widgets/WindowAccessible.h"
#endif
BEGIN_EVENT_TABLE(PrefsDialog, wxDialogWrapper)
EVT_BUTTON(wxID_OK, PrefsDialog::OnOK)
EVT_BUTTON(wxID_CANCEL, PrefsDialog::OnCancel)
@@ -245,6 +249,10 @@ PrefsDialog::PrefsDialog
wxASSERT(factories.size() > 0);
if (!uniquePage) {
mCategories = safenew wxTreebookExt(this, wxID_ANY, mTitlePrefix);
#if wxUSE_ACCESSIBILITY
// so that name can be set on a standard control
mCategories->GetTreeCtrl()->SetAccessible(safenew WindowAccessible(mCategories->GetTreeCtrl()));
#endif
// RJH: Prevent NVDA from reading "treeCtrl"
mCategories->GetTreeCtrl()->SetName(_("Category"));
S.StartHorizontalLay(wxALIGN_LEFT | wxEXPAND, true);