commands and get_element_by_id
This commit is contained in:
+11
-4
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user