Skip to content

Minimal editable text scrolling implementation#23646

Open
ickshonpe wants to merge 32 commits intobevyengine:mainfrom
ickshonpe:editable-text-scrolling
Open

Minimal editable text scrolling implementation#23646
ickshonpe wants to merge 32 commits intobevyengine:mainfrom
ickshonpe:editable-text-scrolling

Conversation

@ickshonpe
Copy link
Copy Markdown
Contributor

@ickshonpe ickshonpe commented Apr 3, 2026

Objective

Add basic support for scrolling text horizontally and vertically to EditableText.

Solution

  • New component TextScroll. Wraps a Vec2 offset that can be used to set the scroll position.
  • Clip overflowing editable text content automatically.
  • New system scroll_editable_text sets TextScroll to keep the cursor within view inside the EditableText's content box.
  • New allow_newline flag on EditableText. Allows insertion of newlines with the enter key.
  • editable_text_system previously ignored TextLayout::linebreak. Now it's possible to change the line break settings.
  • Scrolling only happens after a TextEdit is applied.

The implementation here is extremely simple but it has some flaws:

  • Depending on the width of the node sometimes the cursor can get clipped.
  • allow_newlines: false doesn't block pasting in a section of text with a newline
  • No support for scroll margins yet.
  • Drag-to-scroll seems to work, but I'm not super confident in it and it may need some changes.

Went back and forth over whether ScrollPosition should be used instead of a dedicated component, I think it's probably simpler with TextScroll but not certain. Clipping doesn't use Node's overflow API and is handled automatically during extraction, always targeting the content box.

Testing

cargo run --example multiline_text_input

@kfc35 kfc35 added A-UI Graphical user interfaces, styles, layouts, and widgets A-Text Rendering and layout for characters S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Apr 3, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in UI Apr 3, 2026
@kfc35 kfc35 added the C-Feature A new feature, making something new possible label Apr 3, 2026
@Zeophlite
Copy link
Copy Markdown
Contributor

Screenshot 2026-04-04 at 7 30 33 pm

So I've noticed if you add enough spaces, it will scroll a have character width to the right. Either dragging with the pointer, or just using the left or right cursors can reset it. Seems a little annoying if not intentional, but also I can see it being useful for long text.

Copy link
Copy Markdown
Contributor

@Zeophlite Zeophlite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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 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.

3 participants