Giter Club home page Giter Club logo

bevy-text-edit's Introduction

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 and Interaction into any text entity that needs to be editable:

commands.spawn((
    TextEditable, // Mark text is editable
    Interaction::None, // Mark entity is interactable
    TextBundle::from_section(
        "Input Text 1",
        TextStyle {
            font_size: 20.,
            ..default()
        },
    ),
));

Only text that is focused by clicking gets keyboard input.

License

Please see LICENSE.

Compatible Bevy Versions

bevy bevy_text_edit
0.14 0.1, branch master
0.13 0.0.1-0.0.5

bevy-text-edit's People

Contributors

dothanhtrung avatar

Stargazers

pinkforest(she/her) avatar Katharina Fey avatar

Watchers

 avatar  avatar

bevy-text-edit's Issues

Panic in no_state example

Running the nostate example crashes after removing a piece of text (sorry if you're already aware, you seem to be actively pushing to this repo right now, but I thought I'd let you know :) )

thread 'Compute Task Pool (3)' panicked at /usr/src/debug/rust/rustc-1.78.0-src/library/core/src/str/mod.rs:667:21:
byte index 12 is out of bounds of `Input Text `
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::str::slice_error_fail_rt
   3: core::str::slice_error_fail
   4: core::str::<impl str>::split_at
             at /usr/src/debug/rust/rustc-1.78.0-src/library/core/src/str/mod.rs:667:21
   5: rust_engine::vendor::textedit::listen_keyboard_input
             at ./src/vendor/textedit.rs:244:39
   6: core::ops::function::FnMut::call_mut
             at /usr/src/debug/rust/rustc-1.78.0-src/library/core/src/ops/function.rs:166:5
... lots of spam after this ...

Cheerio!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.