bevy_web_popups

Crates.iobevy_web_popups
lib.rsbevy_web_popups
version
sourcesrc
created_at2024-08-29 12:22:27.20721
updated_at2024-12-02 12:43:51.571868
descriptionAllows to trigger web/dom based popups/alerts and textinput in bevy
homepage
repositoryhttps://github.com/rustunit/bevy_web_popups
max_upload_size
id1356040
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | 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
(extrawurst)

documentation

https://docs.rs/bevy_web_popups

README

bevy_web_popups

crates.io docs.rs discord

Allows to trigger web/dom based popups/alerts and textinput in bevy using wasm-bindgen's web_sys. It is fully customizable but comes with a batteries included default style (see demo below).

See also: bevy_ios_iap, bevy_ios_gamecenter, bevy_ios_notifications, bevy_ios_alerts, bevy_ios_review, bevy_ios_impact & bevy_device_lang

See the crate in action in TinyTakeoff:

demo

Features

  • window.alert()
  • popup dialog with background darkening, textinput, cancel and ok button (fully customizable)

Usage

Add dependency: bevy_web_popups = "0.3"

Initialize Bevy Plugin:

// request initialisation right on startup
app.add_plugins(WebAlertsPlugin);
app.observe(on_event);
fn bevy_system() {
    // trigger native browser alert message popup
    bevy_web_popups::alert("important msg");

    // trigger complex text input popup with a custom title, custom labels for the buttons and asking to spawn default css classes instead of specifying them ourselfs
    bevy_web_popups::show_textinput("set nickname:", "ok", "cancel", true);
}

// system processing events coming from the web plugin
fn on_event(
    trigger: Trigger<WebAlertResponse>,
) {
    let e = trigger.event() 

    if let WebAlertResponse::InputOk(text) = e {
        info!("user confirmed with text: {text}");
    }
}

Bevy version support

bevy this crate
0.15 0.4,main
0.14 0.3
0.14 0.2
0.13 0.1

License

All code in this repository is dual-licensed under either:

at your option. This means you can select the license you prefer.

Your contributions

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 25

cargo fmt