| Ticket UUID: | 595d72d0a685acb8410397679205bcb0eb352465 | |||
| Title: | accessibility.tcl: with a screen reader running, labels and other static widgets become Tab stops | |||
| Type: | Bug | Version: | 9.1 | |
| Submitter: | anonymous | Created on: | 2026-10-03 17:38:20 | |
| Subsystem: | (unused) | Assigned To: | nobody | |
| Priority: | 5 Medium | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2026-10-17 22:52:12 | |
| Resolution: | Wont Fix | Closed By: | kevin_walzer | |
| Closed on: | 2026-10-17 22:52:12 | |||
| Description: |
::tk::accessible::_init runs "$w configure -takefocus 1" (except on aqua) for every widget it initialises, "to ensure correct accessible keyboard navigation". That includes Label and TLabel, TProgressbar, Scrollbar, Canvas and Text. So the Tab order of an application depends on whether a screen reader was running when it started. Tab stops on static text, for screen reader users and for anyone else on the same desktop. In the attached repro.tcl, Tab reaches the ttk::label "Ready." only while Orca runs. Screen reader users read static text with the reader's own review commands (in Orca: the Orca key with the arrow keys, or Orca+B for the whole window), not by tabbing to it, and they expect the same Tab order as everyone else. Suggestion: do not change -takefocus for Label and TLabel, and leave other widgets at their class default unless a specific widget cannot be reached otherwise. | |||
| User Comments: |
kevin_walzer added on 2026-10-05 00:52:28:
I disagree with this proposed change. It would make the behavior on X11 different from macOS and Windows. It is very important for Tk's keyboard navigation functionality to remain consistent. kevin_walzer added on 2026-10-04 15:21:00: How do you suggest we address the focus ring that is drawn when the widget has accessible focus? I want Orca to have feature parity with VoiceOver and NVDA, which draw these elements themselves. 0xjnml added on 2026-10-04 14:55:01: Yes. Orca reads text that does not take focus with its flat review: it
lays out the on-screen objects of the active window and reads them line
by line (desktop layout: KP minus enters flat review, KP 8 reads the
current line, KP 7 and KP 9 move up and down). That is how a label is read
in GTK applications too, where labels are not Tab stops either.
In Tk 9.1 on X11 this did not work at first. Orca read only "blank", and
its debug log shows why:
AXUtilities: [window: 'SW listening test'] from [application:
'scriptweaver'] lacks active state
FOCUS MANAGER: Active window is None
FLAT REVIEW: Frame: None Dialog: None. Top level: None
FLAT REVIEW: 0 on-screen objects found for None
Orca finds the window to review by the ATK "active" state, and the Tk
bridge never sets it. tk_ref_state_set has no ATK_STATE_ACTIVE, and the
"window-activate" signal TkAtkAccessible_FocusHandler emits is a private
GObject signal that the AT-SPI bridge does not forward. That may be why
labels seemed to need focus.
Two changes make it work:
- Serhiy's one-line fix from 3b2c972f29, which gives toplevels the root
as their parent (it is in x11-accessibility-combined.patch on
74d973b49d). Alone it did not help with Orca 48.1.
- The attached active-window.patch, on top of the combined patch: an
idle callback, scheduled from the focus handler, finds the toplevel
that contains the focus (TkGetFocusWin) and announces
state-changed:active on the old and the new one; tk_ref_state_set
reports ATK_STATE_ACTIVE for it; the destroy handler forgets it.
With both, in an application embedding Tk 9.1.0, Orca 48.1 found the
window and its flat review read it line by line, the label included (the
ttk::label "Ready." is not a Tab stop there):
FLAT REVIEW: Frame: [window: 'SW listening test'] ...
FLAT REVIEW: 10 on-screen objects found for [window: 'SW listening test']
'Enable', 'Ready.', 'Open', 'entry', 'Remember', 'selected Small',
'not selected Large', 'text', 'Announce'
(The entries and the text widget read as "entry" and "text" without their
contents, because of the missing text interface described on
48b39019bd.)
The attached active-window-repro.tcl shows the state with an AT-SPI
client. With stock 9.1.0 and the combined patch no window is ever active;
with this patch the main window is active, and when the focus moves to a
second toplevel and back:
state-changed:active on <main window> 0
state-changed:active on 'Second window' 1
state-changed:active on 'Second window' 0
state-changed:active on <main window> 1
Tk's test suite under Xvfb gives the same result with the patch as
without it (9733 tests, the same 15 window-manager failures).
So labels do not need -takefocus 1 for a reader to get their text, and
without it the Tab order stays the same with and without a screen reader.
kevin_walzer added on 2026-10-03 19:06:28: This is by design. In standard Tk, labels do not take focus and it is not clear how the screen reader would capture their text without the -takefocus 1 flag set on X11. Atk's focus is tightly linked with Tk's focus.Are you saying that Orca can capture this text without explicit focus being set by Tk? | |||
Attachments:
- active-window-repro.tcl [download] added by 0xjnml on 2026-10-04 14:55:30. [details]
- active-window.patch [download] added by 0xjnml on 2026-10-04 14:55:30. [details]
- repro.tcl [download] added by anonymous on 2026-10-03 17:38:29. [details]
