Skip to content

Minimal unstyled Text Input with Parley#23282

Merged
alice-i-cecile merged 44 commits intobevyengine:mainfrom
Zeophlite:parley-text-input2
Mar 21, 2026
Merged

Minimal unstyled Text Input with Parley#23282
alice-i-cecile merged 44 commits intobevyengine:mainfrom
Zeophlite:parley-text-input2

Conversation

@Zeophlite
Copy link
Copy Markdown
Contributor

@Zeophlite Zeophlite commented Mar 9, 2026

Objective

Solution

Relevant schedules are:

  • PreUpdate, bevy_ui_widgets::process_text_inputs
  • PostUpdate, bevy_text::apply_text_edits
  • PostUpdate, bevy_ui::editable_text_system

And in render_app:

  • ExtractSchedule, bevy_ui_render::extract_text_editable
  • ExtractSchedule, bevy_ui_render::extract_text_cursor

Testing

  • cargo run --example editable_text

Showcase

text-input-wip4

@IQuick143 IQuick143 added A-Text Rendering and layout for characters D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes A-UI Graphical user interfaces, styles, layouts, and widgets labels Mar 9, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in UI Mar 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 9, 2026

The generated examples/README.md is out of sync with the example metadata in Cargo.toml or the example readme template. Please run cargo run -p build-templated-pages -- update examples to update it, and commit the file change.

CI

docfixs

docs
@Zeophlite Zeophlite force-pushed the parley-text-input2 branch from 9a88110 to 8e06897 Compare March 9, 2026 17:27
@Zeophlite Zeophlite force-pushed the parley-text-input2 branch from 8567f0a to 0a4c802 Compare March 9, 2026 18:14
@alice-i-cecile alice-i-cecile added 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 Mar 9, 2026
/// and provides methods for applying text edits and cursor movements correctly
/// according to Unicode rules.
#[derive(Component)]
#[require(TextLayout, TextFont, TextColor, LineHeight, FontHinting)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I feel like EditableText should just be newtype around PlainEditor and not have any requirements. Maybe no helper functions even.

IMO the basic design should instead use a primary TextInput (or whatever) component that newtypes a string and require's everything. Then the widget's update system keeps the TextInput component synchronised with the PlainEditor's text buffer, for seamless change detection. So users can modify the TextInput's String to update the PlainEditors text buffer and they can use change detection on TextInput to watch for any changes due to edits on the PlainEditor. We can just clone the strings, it doesn't matter as only one input will be active at a time and we aren't building a text editor for giant text files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a pretty big change, and I'm kinda lost on it. Could this be followup?

Copy link
Copy Markdown
Contributor

@ickshonpe ickshonpe Mar 20, 2026

Choose a reason for hiding this comment

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

It's not as complicated as I'm making it sound but we can look into it in a follow up, sure.

Comment on lines +124 to +126
app.register_required_components::<EditableText, Node>()
.register_required_components::<EditableText, TextNodeFlags>()
.register_required_components::<EditableText, ContentSize>();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The primary component should be in this module, then there's no need to bother with this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I want to have a Text2d version in bevy_sprite and reuse EditableText

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This was my rationale too for moving it higher in our crate web.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I want to have a Text2d version in bevy_sprite and reuse EditableText

That would only work exclusively though, wouldn't it? You couldn't enable both an EditableTextPlugin and an EditableText2dPlugin as then the EditableText entities would require both the UI and the sprite components.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR only implements a UI text input though, so it's okay to leave it for now.

@Zeophlite Zeophlite added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Mar 19, 2026
@Zeophlite Zeophlite added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Mar 21, 2026
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Mar 21, 2026
Merged via the queue into bevyengine:main with commit 2de8711 Mar 21, 2026
44 checks passed
@github-project-automation github-project-automation bot moved this from Needs SME Triage to Done in UI Mar 21, 2026
@shanecelis
Copy link
Copy Markdown
Contributor

An exciting merge!

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 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-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Blessed Has a large architectural impact or tradeoffs, but the design has been endorsed by decision makers

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

7 participants