bevy_text_edit

Crates.iobevy_text_edit
lib.rsbevy_text_edit
version
sourcesrc
created_at2024-06-11 06:30:58.709026
updated_at2024-12-03 11:17:51.380934
descriptionBevy plugin for input text
homepage
repositoryhttps://gitlab.com/kimtinh/bevy-text-edit
max_upload_size
id1267825
Cargo.toml error:TOML parse error at line 24, column 1 | 24 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Trung Do (dothanhtrung)

documentation

README

bevy_text_edit

crates.io docs.rs dependency status pipeline status

Quickstart

Plugin

Add plugin TextEditPlugin to the app and define which states it will run in:

#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, States)]
enum GameState {
    #[default]
    Menu,
}

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        // Add the plugin
        .add_plugins(TextEditPlugin::new(vec![GameState::Menu]))
        .run;
}

If you don't care to game state and want to always run input text, use TextEditPluginNoState:

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        // Add the plugin
        .add_plugins(TextEditPluginNoState)
        .add_systems(Startup, setup)
        .run();
}

Component

Insert component TextEditable into any text entity that needs to be editable:

commands.spawn((
    TextEditable::default(), // Mark text is editable
    Text::new("Input Text 1"),
));

Only text that is focused by clicking gets keyboard input.

It is also possible to limit which characters are allowed to enter through filter_in and filter_out attribute. Regex is supported:

commands.spawn((
    TextEditable {
        filter_in: vec!["[0-9]".into(), " ".into()], // Only allow number and space
        filter_out: vec!["5".into()],                // Ignore number 5
    },
    Text::new("Input Text 1"),
));

License

Please see LICENSE.

Compatible Bevy Versions

bevy bevy_text_edit
0.15 0.4, branch master
0.14 0.1-0.3
0.13 0.0.1-0.0.5
Commit count: 50

cargo fmt