dynamically change refs of components #1001
-
I have a VBox with some Buttons (using int &selector to keep track of selected). Behind this Buttons i have a vector entries; holding my data. When i click on one of those buttons i unhide a Modal. Is there a solution for this use case, am i missing something, or do i have recreate and detach the modal object everytime i click a button? //Modal creation
Component ModalComponent(std::function<void()> do_nothing, std::function<void()> hide_modal,
vector<Entry>* &entries,
int &selected
) {
//Problem: get's called only once, on Modal creation
c1 = Checkbox("checkit", &entries->at(selected).checked);
Component component =
Container::Vertical({
c1,
});
component |= Renderer([&](Element inner) {
//any way to update Checkboxes ref to actual selected value?
return vbox({
hbox({
filler(),
center(text(entries->at(selected).name)), //works dynamically
c1->Render()|border,
filler(),
b1->Render(),
}),
}) //
| size(WIDTH, GREATER_THAN, 60) //
| border; //
});
return component;
} would be grateful for any hint :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, I think there are no solution for this.
Yes, I think you would have to recreate the modal object. |
Beta Was this translation helpful? Give feedback.
Yes, I think there are no solution for this.
Yes, I think you would have to recreate the modal object.