Skip to content

Add visual Tab order for RpWidget children - #336

Open
rezabakhshilaktasaraei wants to merge 1 commit into
desktop-app:masterfrom
rezabakhshilaktasaraei:visual-tab-order
Open

Add visual Tab order for RpWidget children#336
rezabakhshilaktasaraei wants to merge 1 commit into
desktop-app:masterfrom
rezabakhshilaktasaraei:visual-tab-order

Conversation

@rezabakhshilaktasaraei

@rezabakhshilaktasaraei rezabakhshilaktasaraei commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Follow-up to the focusNextPrevChild discussion: instead of a window-level override, a container opts in with setVisualTabOrder(true) and keeps its own children ordered in the focus chain by visual position (row bands top-to-bottom, left-to-right, RTL-mirrored) instead of creation order.

The container never traverses on its own: its focusNextPrevChild re-sorts the chain with setTabOrder and delegates to the base implementation, so the existing overrides (FocusNextPrevChildBlocked layer blocking etc.) keep working - they walk the chain and simply see the visual order.

Every Tab stop of every child is placed, not just the child's first and last one: setTabOrder moves a block only for real compound widgets established through a focus proxy, so linking endpoints would leave the widgets between them behind. Inside a child the stops keep the order they already have in the focus chain, so a nested container that opted in composes with the outer one instead of being undone by it - it is also asked to apply first, so a stale nested order isn't preserved by mistake. Hidden descendants are collected too, since focus traversal skips invisible widgets anyway and they are then already in place when shown.

Every widget on the way is queried, so the lazily granted screen reader focus policy is materialized for all of them, and the state re-applies when the screen reader mode changes - detection is asynchronous on Windows and can also be switched on while the app runs.

Reordering is scheduled from layout, visibility and z-order changes of the widget and of its children. refreshVisualTabOrder() covers changes the container can't see - like a list moving its roving Tab-stop from the arrow keys - and Ui::RefreshVisualTabOrder(widget) does the same from a widget created deeper in the tree, by rewiring every container above it.

RpWidget itself gets no data members: the state lives in a small object created only when a container opts in, kept as its child and found back through a dynamic property. Widgets that never opt in store nothing and the override is just that lookup.

Used by tdesktop for the composer row, the chat top bar, the stacked chat bars, the mute bar and the folders sidebar; effectively a no-op outside screen reader mode, where these children are not Tab-focusable.

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.

1 participant