Any way to make an "if true, switch tab"? #513
Answered
by
ArthurSonzogni
ZclipseCode
asked this question in
Q&A
-
Hi, I wanted to create an instance where if a button is pressed, a tab is switched. Is this possible? |
Beta Was this translation helpful? Give feedback.
Answered by
ArthurSonzogni
Nov 22, 2022
Replies: 1 comment
-
Hello! You can add a button, whose action it to change the tab_index: auto button = Button("Switch to tab 7", [&] {
tab_index = 7;
}); For instance: int main(int argc, const char* argv[]) {
auto tab_1 = Renderer([] { return text("Tab 1 content"); });
auto tab_2 = Renderer([] { return text("Tab 2 content"); });
auto tab_3 = Renderer([] { return text("Tab 3 content"); });
int tab_selected = 0;
auto tab_container = Container::Tab(
{
tab_1,
tab_2,
tab_3,
},
&tab_selected);
std::vector<std::string> tab_labels{
"tab_1",
"tab_2",
"tab_3",
};
auto tab_menu = Toggle(&tab_labels, &tab_selected);
auto button = Button("Switch to tab 3", [&] { tab_selected = 2; });
auto global = Container::Vertical({
button,
tab_menu,
tab_container,
});
auto screen = ScreenInteractive::TerminalOutput();
screen.Loop(global);
}
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ArthurSonzogni
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
You can add a button, whose action it to change the tab_index:
For instance: