fix: window zoom
This commit is contained in:
1 parent
6dfe84834d
commit
7f418bbfee
3 files changed
+9
-5
No files matched your search
+2
-3
@@ -4,9 +4,8 @@
|
|||||||
|
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
#[tokio::main]
|
fn main() {
|
||||||
async fn main() {
|
dioxus_desktop::launch(app);
|
||||||
dioxus_desktop::launch(app).await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app(cx: Scope) -> Element {
|
fn app(cx: Scope) -> Element {
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ fn main() {
|
|||||||
|
|
||||||
fn app(cx: Scope) -> Element {
|
fn app(cx: Scope) -> Element {
|
||||||
let window = use_window(cx);
|
let window = use_window(cx);
|
||||||
|
|
||||||
let level = use_state(cx, || 1.0);
|
let level = use_state(cx, || 1.0);
|
||||||
|
|
||||||
cx.render(rsx! {
|
cx.render(rsx! {
|
||||||
input {
|
input {
|
||||||
r#type: "number",
|
r#type: "number",
|
||||||
@@ -16,7 +16,7 @@ fn app(cx: Scope) -> Element {
|
|||||||
oninput: |e| {
|
oninput: |e| {
|
||||||
let num = e.value.parse::<f64>().unwrap_or(1.0);
|
let num = e.value.parse::<f64>().unwrap_or(1.0);
|
||||||
level.set(num);
|
level.set(num);
|
||||||
window.set_zoom_level(num);
|
window.webview.zoom(num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -118,6 +118,11 @@ impl DesktopContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the zoom level of the webview
|
||||||
|
pub fn set_zoom_level(&self, level: f64) {
|
||||||
|
self.webview.zoom(level);
|
||||||
|
}
|
||||||
|
|
||||||
/// opens DevTool window
|
/// opens DevTool window
|
||||||
pub fn devtool(&self) {
|
pub fn devtool(&self) {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
|
|||||||
Reference in new issue
Block a user