working buttons and div

This commit is contained in:
2024-10-18 18:04:25 +02:00
parent d093debfd5
commit 83b9a66515
5 changed files with 171 additions and 103 deletions
+11 -6
View File
@@ -1,6 +1,6 @@
use osui::{
components::{button, div},
oml, App, Component, Params, UpdateResponse,
oml, App, Component, Params,
};
fn main() {
@@ -9,14 +9,19 @@ fn main() {
app.run();
}
fn onclick(c: &mut Component) {
if c.clicked {
c.expr = "Clicked!".to_string();
} else {
c.expr = "click me".to_string()
}
}
fn app_elem(_: Params) -> Component {
oml!(
div {
button("click me"; on_click = |c| {
c.response = UpdateResponse::SetComponent(
oml!(button("Clicked!";))
);
})
button("click me"; on_click = onclick)
button("click me"; y = 2, on_click = onclick)
}
)
}