Clean up a number of examples
This commit is contained in:
30 files changed
+284
-413
No files matched your search
+12
-16
@@ -5,37 +5,33 @@ use dioxus_desktop::use_wry_event_handler;
|
||||
use dioxus_desktop::{Config, WindowCloseBehaviour};
|
||||
|
||||
fn main() {
|
||||
let cfg = Config::new().with_close_behaviour(WindowCloseBehaviour::CloseWindow);
|
||||
|
||||
dioxus_desktop::launch_cfg(app, cfg);
|
||||
Config::new()
|
||||
.with_close_behaviour(WindowCloseBehaviour::CloseWindow)
|
||||
.launch(app)
|
||||
}
|
||||
|
||||
fn app() -> Element {
|
||||
let focused = use_signal(|| false);
|
||||
|
||||
use_wry_event_handler(move |event, _| {
|
||||
if let WryEvent::WindowEvent {
|
||||
use_wry_event_handler(move |event, _| match event {
|
||||
WryEvent::WindowEvent {
|
||||
event: WindowEvent::Focused(new_focused),
|
||||
..
|
||||
} = event
|
||||
{
|
||||
focused.set(*new_focused);
|
||||
}
|
||||
} => focused.set(*new_focused),
|
||||
_ => {}
|
||||
});
|
||||
|
||||
rsx! {
|
||||
div{
|
||||
div {
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
display: "flex",
|
||||
flex_direction: "column",
|
||||
align_items: "center",
|
||||
{
|
||||
if *focused.get() {
|
||||
"This window is focused!"
|
||||
} else {
|
||||
"This window is not focused!"
|
||||
}
|
||||
if *focused() {
|
||||
"This window is focused!"
|
||||
} else {
|
||||
"This window is not focused!"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user