Skip to content

Accessibility: auto-fallback button accessible names - #356

Open
hesam-oxe wants to merge 2 commits into
desktop-app:masterfrom
hesam-oxe:feat/accessibility-base-refactor
Open

Accessibility: auto-fallback button accessible names#356
hesam-oxe wants to merge 2 commits into
desktop-app:masterfrom
hesam-oxe:feat/accessibility-base-refactor

Conversation

@hesam-oxe

Copy link
Copy Markdown

Summary

Ui::AbstractButton now exposes an accessible name automatically for screen readers (NVDA/JAWS/ORCA):

  • If an explicit setAccessibleName() was set, it is used as before.
  • Otherwise the button's toolTip() is used as a fallback.

FlatButton and SettingsButton also call setAccessibleName() from their text.

This means icon-only buttons (close, mute, record, play, etc.) that previously had no accessible name now announce their tooltip, addressing the missing-name reports in telegramdesktop/tdesktop#476. It is the foundational, low-risk part of a larger accessibility effort; focus-navigation, context-menu focus announcements, inline-media InvokePattern, and voice-recording keyboard alternatives remain follow-up work.

Changes

  • ui/abstract_button.cpp / ui/abstract_button.h: added AbstractButton::accessibilityName() override with the explicit-name -> tooltip fallback.
  • ui/widgets/buttons.cpp: FlatButton::setText and SettingsButton::setText set the accessible name from their text.

Related

AbstractButton now exposes an accessible name from an explicit
setAccessibleName() or, as a fallback, its tooltip, so icon-only
buttons (close, mute, record, play) are named for screen readers
without per-call-site fixes. FlatButton and SettingsButton also set
the name from their text.
@CLAassistant

CLAassistant commented Aug 29, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ hesam-oxe
❌ hesam
You have signed the CLA already but the status is still pending? Let us recheck it.

Comment thread ui/abstract_button.cpp
Comment on lines +227 to +235
const auto custom = QWidget::accessibleName();
if (!custom.isEmpty()) {
return custom;
}
const auto tip = toolTip();
if (!tip.isEmpty()) {
return tip;
}
return QString();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary complicated.

Suggested change
const auto custom = QWidget::accessibleName();
if (!custom.isEmpty()) {
return custom;
}
const auto tip = toolTip();
if (!tip.isEmpty()) {
return tip;
}
return QString();
return toolTip();

Comment thread ui/widgets/buttons.cpp

void FlatButton::setText(const QString &text) {
_text = text;
setAccessibleName(text);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FlatButton::accessibilityName already returns _text, this change has no sense

Comment thread ui/widgets/buttons.cpp

void SettingsButton::setText(TextWithEntities &&text) {
_text.setMarkedText(_st.style, text, kMarkupTextOptions, _context);
setAccessibleName(_text.toString());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SettingsButton::accessibilityName already returns _text.toString(), this change has no sense

Make Ui::Accessible::SubItem implement QAccessibleActionInterface so individual message cells (reply quotes and inline media) can be invoked by screen readers, not just whole rows. Adds RpWidget::accessibilityChildSubItemSupportsActions()/Activate() virtuals that owners override to wire the action.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants