-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Per character filter for TextEdits
#23704
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 11 commits into
bevyengine:main
from
ickshonpe:editable_text_filter
Apr 12, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
8d66cfd
Added per character filtering for `EditableText` using an `EditableTe…
ickshonpe 33acbbc
Add default
ickshonpe 996e566
make filter optional for apply_text_edits query
ickshonpe e497a03
added default impl
ickshonpe 3df6b5e
Added new method.
ickshonpe 4736899
Added an `EditableTextFilter` example.
ickshonpe 46d25f0
Wrap the filter fn in an arc instead of a box.
ickshonpe f6f73b3
Made inner value optional, derived default.
ickshonpe be2f7c5
Added `TextCursorStyle`
ickshonpe 0698e31
updated doc comment
ickshonpe 8abcb50
doc comment edit
ickshonpe 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
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,46 @@ | ||
| //! Demonstrates a minimal [`EditableTextFilter`] with an 8-character hex input. | ||
|
|
||
| use bevy::color::palettes::css::{DARK_SLATE_GRAY, YELLOW}; | ||
| use bevy::input_focus::AutoFocus; | ||
| use bevy::prelude::*; | ||
| use bevy::text::{EditableText, EditableTextFilter, TextCursorStyle}; | ||
|
|
||
| fn main() { | ||
| App::new() | ||
| .add_plugins(DefaultPlugins) | ||
| .add_systems(Startup, setup) | ||
| .run(); | ||
| } | ||
|
|
||
| fn setup(mut commands: Commands) { | ||
| commands.spawn(Camera2d); | ||
|
|
||
| commands | ||
| .spawn(Node { | ||
| width: percent(100.), | ||
| height: percent(100.), | ||
| justify_content: JustifyContent::Center, | ||
| align_items: AlignItems::Center, | ||
| ..default() | ||
| }) | ||
| .with_children(|parent| { | ||
| parent.spawn(( | ||
| Node { | ||
| width: px(240.), | ||
| border: px(2.).all(), | ||
| padding: px(8.).all(), | ||
| ..default() | ||
| }, | ||
| EditableText { | ||
| max_characters: Some(8), | ||
| ..default() | ||
| }, | ||
| TextCursorStyle::default(), | ||
| EditableTextFilter::new(|c| c.is_ascii_hexdigit()), | ||
| TextFont::from_font_size(32.), | ||
| BackgroundColor(DARK_SLATE_GRAY.into()), | ||
| BorderColor::all(YELLOW), | ||
| AutoFocus, | ||
| )); | ||
| }); | ||
| } |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer this argument to be an
Option(not a strong feeling)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about it, but it just seemed simpler this way, instead of having to unwrap.