Dynamic rendering of Components in Container #658
-
I have a use-case which involves adding checkboxes (or just for an example, any MenuOption file_menu_option;
file_menu_option.on_enter = fileSelectorCallback;
auto fileSelectorCallback = [&]() {
taskComponents.clear();
taskComponents.push_back(checkbox);
};
Components taskComponents; I'm having issues with rendering the children of the container i.e. taskComponents since putting it in a Renderer would make me lose interactivity with it. For example, this is the solution I tried as well: auto dynamicContentRenderer = ftxui::Renderer([&]() -> ftxui::Element {
std::vector<ftxui::Element> elements;
for (const auto& component : taskComponents) {
elements.push_back(component->Render());
}
return ftxui::vbox(std::move(elements));
}); which works, but I lose interactivity. Great library, btw! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @pralad-p, I wish there was a more "functional" way of doing it, but at least with the If you have any API suggestion that would make your life easier, please don't hesitate to propose it. |
Beta Was this translation helpful? Give feedback.
Hello @pralad-p,
I wish there was a more "functional" way of doing it, but at least with the
ftxui/component
subpart of FTXUI, the best I have to offer is an "imperative" way of doing things: Define aContainer::Vertical({})
and manually useComponentBase::Add
to add childrent to the tree.If you have any API suggestion that would make your life easier, please don't hesitate to propose it.