mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[GH-ISSUE #329] Override/Customize List InputHandler #251
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#251
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jbrodriguez on GitHub (Jul 27, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/329
Currently, KeyTab advances the currentItem, but I'd prefer to use it to switch between tviews.
There's no SetInputHandler for List.
Any suggestion on how to achieve this ?
P.S.: I have SetInputCapture in the app to cycle between tviews with KeyTab and it works, but there's an extra scroll in the listview.
My tree is
@rivo commented on GitHub (Jul 27, 2019):
I'm afraid you'll need to provide more information for me to follow. I don't know what you mean by "tviews", i.e. "switch between tviews", or "an extra scroll in the listview".
You can intercept keyboard events with
SetInputCapture()on every primitive, includingList.If that doesn't help you, please provide some more detailed clarification.
@jbrodriguez commented on GitHub (Jul 27, 2019):
By tviews I meant primitives.
Based on the tree shown above, I want to tab-cycle between List and InputField widgets. Since List captures KeyTab, what happens is the current element in the list is advanced by one (this is what meant by extra scroll) and at the same time I get the effect from my own KeyTab handler (set at the app level), which is to switch to the next widget (my InputField widget).
I was just reading the public api for List, but I forgot that it contains Box, so all those functions are available too.
So I could SetInputCapture on the List to override the default behaviour, but would duplicate code.
That works for me.
Let me If you have any other idea.
Thanks !
@rivo commented on GitHub (Jul 30, 2019):
The
Tabkey has a function for some of the primitives. You can intercept it on the application level by returningnilbut it will affect all other primitives as well. If you only want to intercept theTabkey when yourListhas focus, then you only do it there.So it really depends on how local or how global your key override should be.