Comments (9)
This can be closed.
I added focusPositionRelative(x,y)
to move the focus to one direction within the frame.
big_document() | focusPositionRelative(0, 1) | yframe
from ftxui.
git-tui uses a Scroller component. I might one day make it built in into FTXUI:
https://github.com/ArthurSonzogni/git-tui/blob/master/src/scroller.cpp
Feel free to copy paste.
from ftxui.
Inside a frame, you need to specify which element has the focus, so that FTXUI knows which element it needs to focus one.
if you replace:
g_cmdHistoryContainer->Render() | yframe | flex_grow,
vbox({
g_cmdHistoryContainer->Render(),
text(L"Focus") | focus,
}) | yframe | yflex,
I added an element text(L"Focus")
at the bottom and used focus
to bring focus to it.
from ftxui.
Inside a frame, you need to specify which element has the focus, so that FTXUI knows which element it needs to focus one.
if you replace:
g_cmdHistoryContainer->Render() | yframe | flex_grow,
vbox({ g_cmdHistoryContainer->Render(), text(L"Focus") | focus, }) | yframe | yflex,I added an element
text(L"Focus")
at the bottom and usedfocus
to bring focus to it.
I am interested in understanding how to make a list of entries dynamically scroll. This suggestion does work, however I was not able to scroll back the history to see the commands that scroll out of focus. Any other suggestions here?
from ftxui.
@matthesoundman, I replied in:
#130
Basically, the solution I used above is only about drawing the element, not about they dynamic behavior and reaction with Events.
So was purely implemented within ftxui::dom. To react to user's input, this would need to be implemented within ftxui::component.
from ftxui.
I ended up using this:
// A vertical component that places the focus always on the last child,
// allowing an outer frame to keep that child in view.
class KeepLastInFocusComponent : public ftxui::ComponentBase
{
public:
void Clear()
{
children_.clear();
}
ftxui::Element Render() override
{
std::vector<ftxui::Element> elements;
const size_t lastItem = (children_.size() - 1);
for (size_t i = 0; i < children_.size(); ++i)
{
// Set focus on the last line so that the outer frame keeps it in view.
if (lastItem != i)
{
elements.emplace_back(children_[i]->Render());
}
else
{
elements.emplace_back(children_[i]->Render() | ftxui::focus);
}
}
return vbox(std::move(elements));
}
};
from ftxui.
The ability to scroll up would be good, but I don't want any selection of the text, and I would want the focus to move down to the bottom if new text was added.
from ftxui.
I ended up using this:
[...]
Alternatively, your Component could have been a dom element, since it doesn't have to deal with user's input.
Elements AddFocusBottom(Elements list) {
if (list.size() != 0)
list.back() = focus(std::move(list.back());
return std::move(list)
}
And then replace:
vbox(list)
by:
vbox(AddFocusBottom(list))
from ftxui.
I can add some dom element that put the focus on one side of the component.
Decorator focusTop();
Decorator focusBottom();
Decorator focusLeft();
Decorator focusRight();
If you believe it could be useful.
from ftxui.
Related Issues (20)
- Mouse input does not work correctly on urxvt: Moving the cursor always claims the mouse button is clicked. HOT 4
- Cursor state (blinking, block, underline, ...) is not reset after exiting a program HOT 2
- No definition for `Component Checkbox(CheckboxOption options)` method HOT 4
- Combine canvas and other elements HOT 6
- Checkbox does not `TakeFocus()` when clicked HOT 3
- ftxui_set_options.cmake: unable to compile on windows. HOT 2
- ButtonBase::OnClick ordering HOT 1
- Should Table::SelectRectangle() wrap in the way it does? HOT 1
- input.cpp field length. HOT 2
- Console doesn't clear previous renderer text after new renderer HOT 3
- Canvas background
- Introductory example fails to build HOT 2
- Custom event question HOT 2
- Add example to use system ftxui HOT 3
- "Bug or feature" HOT 3
- fatal error: string_view: No such file or directory HOT 4
- How to check if current terminal supports TUI? HOT 2
- include could not find requested file: .../lib/ftxui/cmake/ftxui-targets.cmake HOT 1
- Is there a way to change the Slider 's color? HOT 1
- [doc-bug] Move Documentation Comments From `.cpp` To `.hpp` For Better LSP Support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ftxui.