Replies: 2 comments
|
A You can still make them behave as one logical widget. Put the shared key bindings on the parent split (or application), and switch focus explicitly with For fuzzy search specifically, I would keep the editable query in a real Conceptually: query_window = Window(BufferControl(buffer=query))
results_window = Window(FormattedTextControl(render_results, key_bindings=result_kb))
root = HSplit([results_window, query_window], key_bindings=shared_kb)A binding that starts search mode can focus Trying to put both controls in one Window would require writing a custom |
|
A Instead, make them two windows in one container (typically an For a fuzzy-filter UI, an especially simple structure is: query = Buffer()
query_window = Window(BufferControl(buffer=query), height=1)
list_window = Window(FormattedTextControl(get_items, focusable=True))
root = HSplit([list_window, query_window])
layout = Layout(root, focused_element=list_window)Then keep the key bindings at the application level when they are meant to work in both places. A binding can inspect You may not need to switch focus for every printable character, though. If the desired UX is "typing always updates the fuzzy query while arrows always navigate the list", an application-level printable-character binding can update the query buffer directly while leaving focus on the list. That often feels more like one compound control and avoids cursor/focus churn. If the behavior is specifically search rather than an arbitrary editable field, also look at |
Uh oh!
There was an error while loading. Please reload this page.
I'm creating a simple TUI that helps me change a terminal theme where i can interactively select a theme name from a list using
FormatedTextControland attached keybindings.Currently, i'm trying to find a way to add
BufferControlto the same window where the text control is to type a word for fuzzy finding the nearest lines in the theme names list for further selection.However, i'm unsure whether it's possible to contain both controls in one window and handle one set of KeyBidings that allows me to type in arbitrary words for fuzzy finding and select the found lines in the list using arrows keys or
ctrl+<key>combinations.What is a proper way to combine these two controls and smoothly switch a focus between them as if they were a single control?
All reactions