mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-24 05:03:06 +00:00
reformated and center aligned example
This commit is contained in:
parent
af5782ff46
commit
981c368933
1 changed files with 12 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
|||
use std::cell::RefCell;
|
||||
|
||||
use crossterm::event::KeyEvent;
|
||||
use crossterm::event::{KeyCode, KeyEvent, MouseEvent};
|
||||
use dioxus::prelude::*;
|
||||
use rink::InputHandler;
|
||||
|
||||
|
@ -9,9 +9,9 @@ fn main() {
|
|||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
let (key, set_key) = use_state(&cx, || "".to_string());
|
||||
let (mouse, set_mouse) = use_state(&cx, || "".to_string());
|
||||
let (size, set_size) = use_state(&cx, || "".to_string());
|
||||
let (key, set_key) = use_state(&cx, || KeyCode::Null);
|
||||
let (mouse, set_mouse) = use_state(&cx, || (0, 0));
|
||||
let (size, set_size) = use_state(&cx, || (0, 0));
|
||||
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
|
@ -20,25 +20,26 @@ fn app(cx: Scope) -> Element {
|
|||
background_color: "red",
|
||||
justify_content: "center",
|
||||
align_items: "center",
|
||||
flex_direction: "column",
|
||||
|
||||
rink::InputHandler {
|
||||
onkeydown: move |evt: KeyEvent| {
|
||||
set_key(format!("{evt:?}"));
|
||||
set_key(evt.code);
|
||||
},
|
||||
},
|
||||
rink::InputHandler {
|
||||
onmousedown: move |evt| {
|
||||
set_mouse(format!("{evt:?}"));
|
||||
onmousedown: move |evt: MouseEvent| {
|
||||
set_mouse((evt.row, evt.column));
|
||||
},
|
||||
},
|
||||
rink::InputHandler {
|
||||
onresize: move |dims| {
|
||||
set_size(format!("{dims:?}"));
|
||||
set_size(dims);
|
||||
},
|
||||
},
|
||||
"keyboard: {key}
|
||||
mouse: {mouse}
|
||||
resize: {size}",
|
||||
"keyboard: {key:?}",
|
||||
"mouse: {mouse:?}",
|
||||
"resize: {size:?}",
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue