-
I want to make a button using images. I am wondering what the nicest way to achieve that is. Right now, I have something like this: let mut clicked = RwSignal::new(false);
img(move || {
if clicked.get() { std::fs::load("btn_down.png") } else { std::fs::load("btn_up.png") }
}) I initially expected this to change on signal when put in an I have it working with a e.g. dyn_stack(
// I don't have a whole stack of things, so monitoring a list of 1 boolean feels strange
// And then every button I add is 3 closures in a trench coat?
// Seems strange for what is essentially just "swap img on event"
move || [clicked.get()]
move |item| item
move |item| img(...)
); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Immediately before posting this question I stumble on the answer, so I'm posting it anyway in order to answer it myself, and maybe help someone in the future. From the looks of the docs, a dynamic container seems to be what I need: https://docs.rs/floem/latest/floem/views/fn.dyn_container.html |
Beta Was this translation helpful? Give feedback.
Immediately before posting this question I stumble on the answer, so I'm posting it anyway in order to answer it myself, and maybe help someone in the future.
From the looks of the docs, a dynamic container seems to be what I need: https://docs.rs/floem/latest/floem/views/fn.dyn_container.html