Skip to content

#306: a control's name lives only in its face - #311

Merged
samitbasu merged 4 commits into
mainfrom
button-names-306
Nov 17, 2026
Merged

samitbasu merged 4 commits into
mainfrom
button-names-306

Conversation

@samitbasu

Copy link
Copy Markdown
Owner

Fixes #306.

A control with a face now takes its accessible name only from that face. This covers the button, toggle, toggle-group member and dropdown (whose face names both its trigger and its menu). .named(..) is gone from their chains and from ButtonOptions, so a control can no longer be named twice.

A text face can still be read by a name other than its text. The name sits in the face itself: Face::text("···").named("The levels between").

The face API

  • "Save" / String: shows the text and is read by it (unchanged).
  • (icon, "Close"): an icon read as "Close" (unchanged).
  • Face::Empty(name): shows nothing and is read by name (unchanged).
  • New: Face::text(text) -> TextFace and TextFace::named(name).
    • named exists only on TextFace.
    • An icon face, already named by its tuple, can't be named again (a compile-fail doctest checks this).

Breaking changes

Before After
b.button(k, "Viewer").named("Role") b.button(k, Face::text("Viewer").named("Role"))
b.button(k, (icon, "Close")).named("Close") b.button(k, (icon, "Close"))
b.button(k, "").named("Undo") b.button(k, Face::Empty("Undo".into()))
b.toggle(k, "B", on).named("Bold") b.toggle(k, Face::text("B").named("Bold"), on)
b.toggle_item(&g, v, "B").named("Bold") b.toggle_item(&g, v, Face::text("B").named("Bold"))
b.dropdown_menu(k, "···").named("The levels between") b.dropdown_menu(k, Face::text("···").named("The levels between"))
ButtonOptions::new().named("Do it") removed: shared options don't carry a per-control name. Name each control's face instead.
Face::Label(String) Face::Label(TextFace). Build it with Face::text(..) or "…".into().

The .named methods on controls without a face stay:

  • select, slider, stepper, checkbox, switch, table, splitter;
  • text fields;
  • overlays and nodes.

Behaviour

Unchanged. The dialog example's Role picker still shows the role and is read as "Role", now through Face::text(..).named("Role").

Tests

  • Compile-fail doctests check that .named(..) no longer compiles on:
    • ButtonChain
    • ButtonOptions
    • ToggleChain
    • DropdownChain
    • an icon Face
  • an_icon_faces_name_is_what_assistive_technology_reads: the AccessKit name is the tuple name for an icon button and an icon toggle, and the text for a text button.
  • an_icon_dropdowns_name_names_its_trigger_and_its_menu
  • a_text_face_with_a_name_is_read_by_the_name_and_shows_the_text: each of these paints its text, while AccessKit reads its name:
    • a button ("Viewer" → "Role");
    • a toggle ("B" → "Bold");
    • a dropdown ("···" → "The levels between").
  • a_renamed_dropdown_names_its_trigger_and_its_menu: the "···" dropdown's open menu and its trigger are both read as "The levels between".
  • Mutations, each caught:
    • Swapping an icon face's name for another fails the icon tests.
    • Swapping the dropdown menu's name fails the dropdown test.
    • Ignoring a TextFace's name fails both renamed-face tests.

Prose for you

  • New TODO(prose) placeholders:
    • Face::text
    • TextFace
    • TextFace::named
    • a sentence in the Face docs
    • the compile-fail examples on ButtonChain, ToggleChain and DropdownChain
  • Two sentences that linked to the removed named were cut down, because stale links break the doc build. Both are in src/owned/button.rs:
    • Face::name: now "What assistive technology reads."
    • the ButtonChain docs: now "An empty label or name is reported as Unnamed."

Stale prose I left alone:

  • docs/overlays.md:690 lists .named among DropdownChain's methods.

cargo xtask ci exits 0 on ea6c87d (main fdb6b62).

🤖 Generated with Claude Code

https://claude.ai/code/session_01PWiKKf74MNWrhkW1CvKVUP

samitbasu and others added 4 commits November 17, 2026 08:19
`ButtonChain::named` and `ButtonOptions::named` are gone. A text face's
name is its text, an icon face's is its `(icon, "Name")` tuple and an
empty face's is `Face::Empty(name)`, so a button can no longer be named
twice with no documented winner.

Breaking: `.named(..)` on a button or on `ButtonOptions` no longer
compiles. A button whose accessible name differs from its label (the
dialog example's Role picker) is now read by its label.

Tests: compile-fail doctests for both methods; the AccessKit name of an
icon button, an icon toggle, a text button and an icon dropdown's
trigger and menu.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKf74MNWrhkW1CvKVUP
`ToggleChain::named` (and so a toggle-group member's) and
`DropdownChain::named` are gone. A dropdown's trigger and menu are both
named by its face.

Breaking: `.named(..)` on a toggle or dropdown no longer compiles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKf74MNWrhkW1CvKVUP
`Face::text("···").named("The levels between")` shows the text and is
read by the name, for buttons, toggles, toggle-group members and
dropdowns (whose trigger and menu both take it). The name still has one
source, the face: `Face::Label` now holds a `TextFace`, and `named` is
only on it, so an icon face, named by its tuple, cannot be named again.

The dialog example's Role picker keeps its name: it shows the role and
is read as "Role".

Breaking: `Face::Label` holds a `TextFace`, not a `String`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKf74MNWrhkW1CvKVUP
@samitbasu

Copy link
Copy Markdown
Owner Author

Gate (my run on ea6c87d with current main): cargo xtask ci (with fuzz) exits 0. This implements the user's #306 decision (2026-11-17). The change is to accessible names only, with nothing visible. Merging (the user authorised merges).

@samitbasu
samitbasu merged commit 9e220d8 into main Nov 17, 2026
4 checks passed
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.

Button: an icon face's name and .named() can both set the name

1 participant