bevy_simple_text_input 0.14.1

Bevy plugin for a simple single-line text input widget.
Documentation
//! An example showing a masked input for passwords.

use bevy::prelude::*;
use bevy_simple_text_input::{
    TextInput, TextInputMaxLengthMessage, TextInputPlugin, TextInputSettings, TextInputSystem,
    TextInputTextColor, TextInputTextFont, TextInputValue,
};

const BORDER_COLOR_ACTIVE: Color = Color::srgb(0.75, 0.52, 0.99);
const TEXT_COLOR: Color = Color::srgb(0.9, 0.9, 0.9);
const BACKGROUND_COLOR: Color = Color::srgb(0.15, 0.15, 0.15);

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(TextInputPlugin)
        .add_systems(Startup, setup)
        .add_systems(Update, listener.after(TextInputSystem))
        .run();
}

fn setup(mut commands: Commands) {
    commands.spawn(Camera2d);

    commands
        .spawn(Node {
            width: Val::Percent(100.0),
            height: Val::Percent(100.0),
            align_items: AlignItems::Center,
            justify_content: JustifyContent::Center,
            ..default()
        })
        .with_children(|parent| {
            parent.spawn((
                Node {
                    width: Val::Px(200.0),
                    border: UiRect::all(Val::Px(5.0)),
                    padding: UiRect::all(Val::Px(5.0)),
                    ..default()
                },
                BorderColor::all(BORDER_COLOR_ACTIVE),
                BackgroundColor(BACKGROUND_COLOR),
                TextInput,
                TextInputValue("password".to_string()),
                TextInputTextFont(TextFont {
                    font_size: 34.,
                    ..default()
                }),
                TextInputTextColor(TextColor(TEXT_COLOR)),
                TextInputSettings {
                    mask_character: Some('*'),
                    retain_on_submit: true,
                    // We're configuring this value in the example to demonstrate the
                    // functionality, but you probably don't want to limit the length
                    // of passwords.
                    max_length: Some(12),
                },
            ));
        });
}

fn listener(mut events: MessageReader<TextInputMaxLengthMessage>) {
    for event in events.read() {
        info!("{:?} max length reached.", event.entity);
    }
}