Documentation and examples

Also derive useful traits
This commit is contained in:
Reinis Mazeiks committed 2022-05-07 00:49:47 +03:00
1 parent 0dbd3e370e
commit 3c447d7266
2 files changed
+36 -2

No files matched your search

@@ -10,6 +10,8 @@ fn app(cx: Scope) -> Element {
let page_coordinates = use_state(&cx, || "".to_string());
let screen_coordinates = use_state(&cx, || "".to_string());
let element_coordinates = use_state(&cx, || "".to_string());
let buttons = use_state(&cx, || "".to_string());
let modifiers = use_state(&cx, || "".to_string());
let container_style = r#"
display: flex;
@@ -30,6 +32,9 @@ fn app(cx: Scope) -> Element {
element_coordinates.set(format!("{:?}", mouse_data.element_coordinates()));
// Note: client coordinates are also available, but they would be the same as the page coordinates in this example, because there is no scrolling.
buttons.set(format!("{:?}", mouse_data.held_buttons()));
modifiers.set(format!("{:?}", mouse_data.modifiers()));
};
cx.render(rsx! (
@@ -39,10 +44,13 @@ fn app(cx: Scope) -> Element {
div {
style: "{rect_style}",
onmousemove: update_mouse_position,
prevent_default: "mousedown",
}
div {"Page coordinates: {page_coordinates}"},
div {"Screen coordinates: {screen_coordinates}"},
div {"Element coordinates: {element_coordinates}"},
div {"{buttons}"},
div {"{modifiers}"},
}
))
}