Can I generate button elements at runtime? #795
|
OBJECTIVE: It could just be my lack of basic Rust knowledge, I've just been working in this language for a few months. WHAT I CAN DO: THE ERROR: Inside the code for my app (called Hello), I try to dynamically generate buttons like so main.rs I receive the following error
And here is how I declare my UserButton class main.rs Any help is appreciate. Thanks! |
Replies: 6 comments
|
Yes it is!
If you want a 2d grid of buttons I have that in my project here. (Just a warning its quite confusing, just get a |
|
@13r0ck Cool! Thanks for the reply. I did just try a similar strategy before this (making a Vec of button::State in my main struct) and I managed to create another error. Here is the code in I'm using
Do you have a quick fix for that? I will take a look at the links you provided as well. |
|
No no quick fix, unfortunately you attempt is completely wrong :) |
|
:) Thanks. I guess I'll be learning something new then.
|
|
@13r0ck Looks like the answer for me was just two things
You rock man! 🎸 |
|
Congrats! |


No no quick fix, unfortunately you attempt is completely wrong :)
You need to
iter_mut()though the vec ofbutton::States. Basically no way to do it without the.foldsomething like