commands and get_element_by_id

This commit is contained in:
2024-11-22 09:33:02 +01:00
parent 10c8f6d0ca
commit cc0ea4a9f5
6 changed files with 123 additions and 77 deletions
+11 -4
View File
@@ -1,17 +1,21 @@
// use std::sync::Arc;
use osui::prelude::*;
pub struct App {}
fn main() {
// let something = Arc::new(App {});
while osui::run(&mut app()) {}
}
fn app() -> Element {
rsx! { styling: Some(styles()),
button { class: "btn", "Hello, World!" }
button { class: "btn", on_click: Handler::new(|_, _, document| {
if let Some(txt) = document.get_element_by_id::<Text>("txt") {
txt.children.set_text("edited");
}
}), "Hello, World!" }
text { id: "txt", "Some text!" }
}
}
@@ -20,5 +24,8 @@ fn styles() -> Css {
.btn: clicked {
color: Blue
}
.btn: hover {
color: Red
}
}
}