working buttons and div
This commit is contained in:
+11
-6
@@ -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)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user