FTXUI
FTXUI copied to clipboard
How to scroll elements , not components
If I have Components like menu, radiobox, etc in container, it is scrollable. But elements don't seem to be scrollable.
#include <ftxui/component/component.hpp>
#include <ftxui/component/screen_interactive.hpp>
#include <ftxui/dom/elements.hpp>
#include <ftxui/screen/screen.hpp>
#include <iostream>
ftxui::Element get_document() {
using namespace ftxui;
auto cell = [](const char* t) { return text(t) | border; };
auto document = //
gridbox({
{
cell("north-west"),
cell("north"),
cell("north-east"),
},
{
cell("center-west"),
gridbox({
{
cell("center-north-west"),
cell("center-north-east"),
},
{
cell("center-south-west"),
cell("center-south-east"),
},
}),
cell("center-east"),
},
{
cell("south-west"),
cell("south"),
cell("south-east"),
},
});
return document;
}
int main() {
using namespace ftxui;
auto cell = [](const char* t) { return text(t) | border; };
int n;
std::cin >> n;
if (n == 1) {
Element document = get_document();
auto component =
Renderer([document] { return document | vscroll_indicator | frame; });
auto screen = ScreenInteractive::FullscreenAlternateScreen();
screen.Loop(component);
} else {
Elements documents;
for (int i = 0; i < 10; i++) {
auto document = get_document();
document |= border;
documents.push_back(document);
}
auto component = Renderer(
[documents] { return vbox(documents) | vscroll_indicator | frame; });
auto screen = ScreenInteractive::FullscreenAlternateScreen();
screen.Loop(component);
}
return 0;
}
neither the gridbox seems to scroll, nor the vbox containing multiple gridbox