mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-10 06:34:20 +00:00
dd4547d753
Add functions like window() and router() to allow dynamically grabbing global contexts without have to use the hook variants. Deprecates the existing hook variants to discourage folks from adding more noise to their codebases.
22 lines
492 B
Rust
22 lines
492 B
Rust
use dioxus::prelude::*;
|
|
|
|
fn main() {
|
|
dioxus_desktop::launch(app);
|
|
}
|
|
|
|
fn app(cx: Scope) -> Element {
|
|
let level = use_state(cx, || 1.0);
|
|
|
|
cx.render(rsx! {
|
|
input {
|
|
r#type: "number",
|
|
value: "{level}",
|
|
oninput: |e| {
|
|
if let Ok(new_zoom) = e.value.parse::<f64>() {
|
|
level.set(new_zoom);
|
|
dioxus_desktop::window().webview.zoom(new_zoom);
|
|
}
|
|
}
|
|
}
|
|
})
|
|
}
|