1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 15:49:41 +02:00

Applied accessibility patch from David that I missed.

From David's message:

   "solution to the problem of getting jaws to read the updated
   name after choosing start/stop monitoring on the menu"
This commit is contained in:
lllucius 2015-01-19 17:47:39 +00:00
parent 10f62cdae5
commit 3d420e019c
2 changed files with 65 additions and 35 deletions

View File

@ -233,7 +233,8 @@ Meter::Meter(AudacityProject *project,
mNumBars(0),
mLayoutValid(false),
mBitmap(NULL),
mIcon(NULL)
mIcon(NULL),
mAccSilent(false)
{
mStyle = mDesiredStyle;
@ -1913,8 +1914,22 @@ void Meter::ShowMenu(const wxPoint & pos)
menu->Append(OnPreferencesID, _("Preferences..."));
mAccSilent = true; // temporarily make screen readers say (close to) nothing on focus events
PopupMenu(menu, pos);
/* if stop/start monitoring was chosen in the menu, then by this point
OnMonitoring has been called and variables which affect the accessibility
name have been updated so it's now ok for screen readers to read the name of
the button */
mAccSilent = false;
#if wxUSE_ACCESSIBILITY
GetAccessible()->NotifyEvent(wxACC_EVENT_OBJECT_FOCUS,
this,
wxOBJID_CLIENT,
wxACC_SELF);
#endif
delete menu;
}
@ -2195,44 +2210,52 @@ wxAccStatus MeterAx::GetName(int WXUNUSED(childId), wxString* name)
{
Meter *m = wxDynamicCast(GetWindow(), Meter);
*name = m->GetName();
if (name->IsEmpty())
if (m->mAccSilent)
{
*name = m->GetLabel();
}
if (name->IsEmpty())
{
*name = _("Meter");
}
if (m->mMonitoring)
{
*name += wxString::Format(_(" Monitoring "));
}
else if (m->mActive)
{
*name += wxString::Format(_(" Active "));
}
float peak = 0.;
for (int i = 0; i < m->mNumBars; i++)
{
peak = wxMax(peak, m->mBar[i].peakPeakHold);
}
if (m->mDB)
{
*name += wxString::Format(_(" Peak %2.f dB"), (peak * m->mDBRange) - m->mDBRange);
*name = wxT(""); // Jaws reads nothing, and nvda reads "unknown"
}
else
{
*name += wxString::Format(_(" Peak %.2f "), peak);
}
if (m->IsClipping())
{
*name += wxString::Format(_(" Clipped "));
*name = m->GetName();
if (name->IsEmpty())
{
*name = m->GetLabel();
}
if (name->IsEmpty())
{
*name = _("Meter");
}
if (m->mMonitoring)
{
*name += wxString::Format(_(" Monitoring "));
}
else if (m->mActive)
{
*name += wxString::Format(_(" Active "));
}
float peak = 0.;
for (int i = 0; i < m->mNumBars; i++)
{
peak = wxMax(peak, m->mBar[i].peakPeakHold);
}
if (m->mDB)
{
*name += wxString::Format(_(" Peak %2.f dB"), (peak * m->mDBRange) - m->mDBRange);
}
else
{
*name += wxString::Format(_(" Peak %.2f "), peak);
}
if (m->IsClipping())
{
*name += wxString::Format(_(" Clipped "));
}
}
return wxACC_OK;
@ -2241,7 +2264,12 @@ wxAccStatus MeterAx::GetName(int WXUNUSED(childId), wxString* name)
// Returns a role constant.
wxAccStatus MeterAx::GetRole(int WXUNUSED(childId), wxAccRole* role)
{
*role = wxROLE_SYSTEM_BUTTONDROPDOWN;
Meter *m = wxDynamicCast(GetWindow(), Meter);
if (m->mAccSilent)
*role = wxROLE_NONE; // Jaws and nvda both read nothing
else
*role = wxROLE_SYSTEM_BUTTONDROPDOWN;
return wxACC_OK;
}

View File

@ -274,6 +274,8 @@ class Meter : public wxPanel
bool mHadKeyDown;
#endif
bool mAccSilent;
friend class MeterAx;
DECLARE_EVENT_TABLE()