-
|
I am trying to have a modal component that contains an However, I can't use the Here my code: #include <ftxui/component/component.hpp>
#include <ftxui/component/component_options.hpp>
#include <ftxui/component/mouse.hpp>
#include <ftxui/component/screen_interactive.hpp>
#include <ftxui/dom/elements.hpp>
using namespace ftxui;
Component ModalComponent() {
class Impl : public ComponentBase {
Component input;
public:
explicit Impl(void) {
input = Input("ABC");
}
Element OnRender(void) override {
SetActiveChild(input); // Doesn't work
return input->Render();
}
bool Focusable(void) const final {
return true;
}
};
return Make<Impl>();
}
int main(void) {
auto screen = ScreenInteractive::TerminalOutput();
bool show_modal = false;
auto main_component = Checkbox("show modal?", &show_modal);
auto modal_component = ModalComponent();
modal_component |= CatchEvent([&](Event e) {
if (e == Event::Character("q")) {
show_modal = false;
return true;
}
return false;
});
main_component |= Modal(modal_component, &show_modal);
screen.Loop(main_component);
return 0;
}The Is there any way to make the Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
The issue is that your explicit Impl() {
input = Input("ABC");
Add(input);
} |
Beta Was this translation helpful? Give feedback.
The issue is that your
ModalComponentdoesn't add the Input child component to the component tree. AddAdd(input)in the constructor to fix it.