-
-
Notifications
You must be signed in to change notification settings - Fork 426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to scroll elements , not components #907
Comments
Hello, You have to use the See: FTXUI/include/ftxui/dom/elements.hpp Lines 151 to 159 in 5a9ef87
See also the radiobox implementation. -- Alternatively, you might want to look at: |
Thanks, #include <ftxui/component/component.hpp>
#include <ftxui/component/screen_interactive.hpp>
#include <ftxui/dom/elements.hpp>
#include <ftxui/screen/screen.hpp>
#include <iostream>
#include "scroller.hpp"
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; });
component |= Scroller;
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); });
component |= Scroller;
auto screen = ScreenInteractive::FullscreenAlternateScreen();
screen.Loop(component);
}
return 0;
}
I am using Scroller , both works . But This Scroller if applied to component makes component unresponsive to event , but I use ftxui::ComponentDecorator vscroll_renderer = ftxui::Renderer(
[](ftxui::Element e) { return e | ftxui::vscroll_indicator | ftxui::frame; }); Is this the correct way? Also I want to ask, is this the correct way to convert element to Component, am I doing it correct,
or is there some better way ? Also in catch event is there a way to map bindings to scroll to top /bottom , e.g. something vim like gg for top , G for bottom. Anyway, thanks again. |
If I have Components like menu, radiobox, etc in container, it is scrollable. But elements don't seem to be scrollable.
neither the gridbox seems to scroll, nor the vbox containing multiple gridbox
The text was updated successfully, but these errors were encountered: