Skip to content

EditableText::visible_width#23717

Open
ickshonpe wants to merge 6 commits intobevyengine:mainfrom
ickshonpe:editable-text-visible-width
Open

EditableText::visible_width#23717
ickshonpe wants to merge 6 commits intobevyengine:mainfrom
ickshonpe:editable-text-visible-width

Conversation

@ickshonpe
Copy link
Copy Markdown
Contributor

@ickshonpe ickshonpe commented Apr 8, 2026

Objective

Horizontal equivalent of the visible_lines option.

Allow users to set the width of a text input widget by number of glyphs. Or for proportional fonts, where the glyph widths are non-uniform, it would use a multiple of the advance width for "0".

Solution

  • New visible_width: Option<f32> field on EditableText.
  • TextInputMeasure now has both a width and height field and both are Option<f32>.
  • update_editable_text_content_size calculates the width if visible_width is Some.
  • The width is calculated by multiplying the advance width of "0" by the visible_width (if set) and the current scale factor.

Testing

I altered the hex input in the feathers example to so it's sized to fit 10 characters (includes space for the cursor).

cargo run --example feathers --features="experimental_bevy_feathers"

@ickshonpe ickshonpe added C-Feature A new feature, making something new possible A-UI Graphical user interfaces, styles, layouts, and widgets A-Text Rendering and layout for characters D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels Apr 9, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in UI Apr 9, 2026
@ickshonpe ickshonpe added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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 S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

1 participant