Skip to content

Conversation

@ickshonpe
Copy link
Contributor

@ickshonpe ickshonpe commented Dec 6, 2025

Objective

Allow picking text per section.

Fixes #17477

Solution

  • Add optional text components to NodeQuery.
  • New helper function, pick_ui_text. Finds if a text section is hovered and returns its id.
  • Add the entities of text sections to hit_nodes when hovered.
  • Add the target camera entity to hit_nodes, instead of querying for it a second time.
  • When a picked node is a text node and require_markers is enabled, check if the hit section entity has a Pickable component, instead of the text node.

This design might need to be changed later to allow for text selection and copying. But there doesn't seem any need to overcomplicate things for now by considering it.

Testing

I added observers to the TextBackgroundColors example's text entities. The observers turn a text section's text color to white when the pointer hovers them.

cargo run --example text_background_colors

…it a second time.

* Add the entity of the text section hit to `hit_nodes`.

* When picked node is a text node and `require_markers` is enabled, check if the hit section entity is picked.
…The observers turn the section's color to white when the pointer hovers them.
@ickshonpe ickshonpe changed the title Text section picking Per text section picking Dec 6, 2025
@ickshonpe ickshonpe added A-UI Graphical user interfaces, styles, layouts, and widgets A-Text Rendering and layout for characters labels Dec 6, 2025
@ickshonpe ickshonpe changed the title Per text section picking UI per text section picking Dec 6, 2025
@ickshonpe ickshonpe added A-Picking Pointing at and selecting objects of all sorts D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes C-Feature A new feature, making something new possible M-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Picking Pointing at and selecting objects of all sorts A-Text Rendering and layout for characters A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes M-Release-Note Work that should be called out in the blog due to impact S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow for click detection (mouse picking) of a TextSpan

1 participant