Minimal unstyled Text Input with Parley#23282
Minimal unstyled Text Input with Parley#23282alice-i-cecile merged 44 commits intobevyengine:mainfrom
Conversation
|
The generated |
9a88110 to
8e06897
Compare
8567f0a to
0a4c802
Compare
| /// and provides methods for applying text edits and cursor movements correctly | ||
| /// according to Unicode rules. | ||
| #[derive(Component)] | ||
| #[require(TextLayout, TextFont, TextColor, LineHeight, FontHinting)] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This is a pretty big change, and I'm kinda lost on it. Could this be followup?
There was a problem hiding this comment.
It's not as complicated as I'm making it sound but we can look into it in a follow up, sure.
| app.register_required_components::<EditableText, Node>() | ||
| .register_required_components::<EditableText, TextNodeFlags>() | ||
| .register_required_components::<EditableText, ContentSize>(); |
There was a problem hiding this comment.
The primary component should be in this module, then there's no need to bother with this.
There was a problem hiding this comment.
I want to have a Text2d version in bevy_sprite and reuse EditableText
There was a problem hiding this comment.
This was my rationale too for moving it higher in our crate web.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This PR only implements a UI text input though, so it's okay to leave it for now.
Co-authored-by: ickshonpe <david.curthoys@googlemail.com>
|
An exciting merge! |
Objective
Solution
EditableTextcomponent wraps aparley::PlainEditorTextEdititemsPlainEditorfor layout, and render from thereRelevant schedules are:
PreUpdate,bevy_ui_widgets::process_text_inputsPostUpdate,bevy_text::apply_text_editsPostUpdate,bevy_ui::editable_text_systemAnd in
render_app:ExtractSchedule,bevy_ui_render::extract_text_editableExtractSchedule,bevy_ui_render::extract_text_cursorTesting
cargo run --example editable_textShowcase