-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Minimal unstyled Text Input with Parley #23282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alice-i-cecile
merged 44 commits into
bevyengine:main
from
Zeophlite:parley-text-input2
Mar 21, 2026
Merged
Changes from all commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
2edb3b2
Initial port to parley
alice-i-cecile 2a0db90
Added `TextCursorStyle` component.
ickshonpe 3853701
Added cursor and selection rects to TextLayoutInfo
ickshonpe ec07639
Added cursor and selection rects rendering
ickshonpe 0057f73
Move cursor rendering to own file
Zeophlite 8b45b19
editable_text.rs -> text_editable.rs
Zeophlite e7a44e5
Move TextEdit to own file
Zeophlite ebc1d61
Move editing.rs to cursor.rs
Zeophlite 04c411b
WIP Input Text
Zeophlite 8e06897
CI
Zeophlite 0a4c802
CI
Zeophlite 1a8b3cc
Clippy
Zeophlite 85fd548
Apply suggestions from code review
Zeophlite 8a8cc57
Further feedback
Zeophlite ca33995
more review
Zeophlite f2195de
Merge remote-tracking branch 'origin/main' into parley-text-input2
Zeophlite e66f0b5
default
Zeophlite 5b3b8ec
Support changing font size
Zeophlite 4fe43dc
Enable selection
Zeophlite 3bb5c74
Only need remeasure on font size change
Zeophlite c93be22
CI
Zeophlite f6610b7
Fix rects
Zeophlite 3a50a41
Merge remote-tracking branch 'origin/main' into parley-text-input2
Zeophlite ae3cc93
Try without fontconfig
Zeophlite 19459c3
Partial parley-input
ickshonpe a1fe756
Remove unneeded
Zeophlite 38c3363
Fixes
Zeophlite cd1c713
CI
Zeophlite 3d62f8a
Fix up cursor width
Zeophlite ad6cde0
Clean up
Zeophlite 09eed51
Apply suggestions from code review
Zeophlite c1449b4
Review
Zeophlite 6cc5689
Merge remote-tracking branch 'origin/main' into parley-text-input2
Zeophlite c59943d
Use TextBrush now
Zeophlite 49d7294
cat walked over my keyboard
Zeophlite dd060e6
Fix outdated instructions in example
alice-i-cecile 448b0e0
Apply suggestions from code review
Zeophlite b6c2576
Cleanup
Zeophlite 443161c
Merge remote-tracking branch 'origin/main' into parley-text-input2
Zeophlite 577b694
Change to observer
Zeophlite 227e757
Doc
Zeophlite 24a0298
Rm extract_text_editable from bevy_ui_render
Zeophlite fd4872d
CI
Zeophlite cd799ff
text_system Without<EditableText>
Zeophlite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| use bevy_color::{ | ||
| palettes::css::{GREEN, RED}, | ||
| Alpha as _, Color, | ||
| }; | ||
| use bevy_ecs::component::Component; | ||
|
|
||
| /// Controls text cursor appearance. | ||
| /// | ||
| /// When this component on the same entity as an [`EditableText`](`crate::EditableText`) , | ||
| /// and the [`UiRenderPlugin`](https://docs.rs/bevy/latest/bevy/ui_render/struct.UiRenderPlugin.html) | ||
| /// is active, a simple rectangle will be drawn for the cursor. | ||
| /// This is an optional component, to allow for stylistic cursors. | ||
| #[derive(Component, Clone, Copy, Debug, PartialEq)] | ||
| pub struct TextCursorStyle { | ||
| /// Color of the cursor | ||
| pub color: Color, | ||
| /// Background color of selected text | ||
| pub selection_color: Color, | ||
| } | ||
|
|
||
| impl Default for TextCursorStyle { | ||
| fn default() -> Self { | ||
| Self { | ||
| color: RED.into(), | ||
| selection_color: Color::from(GREEN).with_alpha(0.5), | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| use bevy_reflect::Reflect; | ||
| use parley::PlainEditorDriver; | ||
| use smol_str::SmolStr; | ||
|
|
||
| use crate::TextBrush; | ||
|
|
||
| /// Deferred text input edit and navigation actions applied by the `apply_text_edits` system. | ||
| #[derive(Debug, Clone, PartialEq, Eq, Reflect)] | ||
| pub enum TextEdit { | ||
| /// Insert a character at the cursor. If there is a selection, replaces the selection with the character instead. | ||
| /// | ||
| /// Typically generated in response to keyboard text input events. | ||
| /// | ||
| /// This is intended to insert a single Unicode grapheme cluster, such as a letter, digit, punctuation mark, or emoji. | ||
| Insert(SmolStr), | ||
| /// Delete the character behind the cursor. | ||
| /// If there is a selection, deletes the selection instead. | ||
| /// | ||
| /// Typically generated in response to the backspace key. | ||
| /// | ||
| /// This operation removes an entire Unicode grapheme cluster, which may consist of multiple bytes, | ||
| /// shifting the cursor position accordingly. | ||
| Backspace, | ||
| /// Delete the character at the cursor. | ||
| /// If there is a selection, deletes the selection instead. | ||
| /// | ||
| /// Typically generated in response to the delete key. | ||
| /// | ||
| /// This operation removes an entire Unicode grapheme cluster, which may consist of multiple bytes, | ||
| /// shifting the cursor position accordingly. | ||
| Delete, | ||
| /// Moves the cursor by one position to the right. | ||
| /// | ||
| /// Typically generated in response to the right key. | ||
| MoveCursorRight, | ||
| /// Moves the cursor by one position to the left. | ||
| /// | ||
| /// Typically generated in response to the left key. | ||
| MoveCursorLeft, | ||
| /// Move selection on to the right. | ||
| /// | ||
| /// Typically generated in response to shift and the right key. | ||
| SelectRight, | ||
| /// Move selection on to the left. | ||
| /// | ||
| /// Typically generated in response to shift and the left key. | ||
| SelectLeft, | ||
| } | ||
|
|
||
| /// Takes a `TextEdit` and applies to `PlainEditorDriver` | ||
| pub fn apply_edit<'a>( | ||
| edit: TextEdit, | ||
| mut driver: PlainEditorDriver<'a, TextBrush>, | ||
| ) -> PlainEditorDriver<'a, TextBrush> { | ||
| match edit { | ||
| TextEdit::Insert(str) => driver.insert_or_replace_selection(&str), | ||
| TextEdit::Backspace => driver.backdelete(), | ||
| TextEdit::Delete => driver.delete(), | ||
| TextEdit::MoveCursorRight => driver.move_right(), | ||
| TextEdit::MoveCursorLeft => driver.move_left(), | ||
| TextEdit::SelectRight => driver.select_right(), | ||
| TextEdit::SelectLeft => driver.select_left(), | ||
| } | ||
| driver | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.