Browse Source

example: add `window_zoom` example

YuKun Liu 3 năm trước cách đây
mục cha
commit
77c22161b9
1 tập tin đã thay đổi với 23 bổ sung0 xóa
  1. 23 0
      examples/window_zoom.rs

+ 23 - 0
examples/window_zoom.rs

@@ -0,0 +1,23 @@
+use dioxus::desktop::use_window;
+use dioxus::prelude::*;
+
+fn main() {
+    dioxus::desktop::launch(app);
+}
+
+fn app(cx: Scope) -> Element {
+    let window = use_window(&cx);
+
+    let level = use_state(&cx, || 1.0);
+
+    window.set_zoom_level(*level.get());
+    cx.render(rsx! {
+        input {
+            r#type: "number",
+            value: "{level_display}",
+            oninput: |e| {
+                level.set(e.value.parse::<f64>().unwrap_or_default())
+            }
+        }
+    })
+}