Skip to content

Selectable text: render text nodes through egui Labels from the measured galley #39

Closed

Description

@samitbasu

Raised by the user: text in chat_shell can't be selected, although egui labels are selectable by default.

Cause

bullseye's text primitive measures a galley during layout and paints it directly (painter.galley(..)). It never creates an egui Label, so egui's LabelSelectionState never sees it: no selection, no copy.

Proposal

  • For selectable text nodes, draw an egui Label built from the measured galley (WidgetText::Galley(Arc<Galley>)) at exactly the node's content rect, inside the node's Ui. Layout stays bullseye's, the text is measured once, and egui handles selection (including across several labels in the same layer) and Ctrl+C.
  • Default rule, as in CSS:
    • text is selectable;
    • text inside a node that senses clicks or drags is not, so buttons and clickable rows keep their clicks;
    • Tailwind-style overrides select_text() and select_none().
  • Library-drawn controls (owned buttons, checkbox labels, M4c) are select_none by default.
  • Selection colours come from the style (M4c contract): selection background and selected text colour.

Tests (kittest)

  • Dragging across a paragraph selects it, and Ctrl+C copies the text.
  • A drag across two adjacent paragraphs selects across both.
  • Clicking text inside a clickable row still activates the row and selects nothing.
  • select_none text can't be selected.
  • Layout is identical with and without selection.
  • The cost per text node in a long list goes into the M8 benchmark.

Where

Proposed for v0.1, in M4c alongside the owned widgets (it shares the "what senses" rules), or right after it. The user decides.

Activity

  1. samitbasu commented on Nov 8, 2026

    @samitbasu
    OwnerAuthor

    Decided by the user: in v0.1, landing in M4c-1 (see #19).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions