[GH-ISSUE #329] Override/Customize List InputHandler #251

Closed
opened 2026-03-04 01:03:21 +03:00 by kerem · 3 comments
Owner

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

app
|---flex
      |--- list
      |--- input
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 ``` app |---flex |--- list |--- input ```
kerem closed this issue 2026-03-04 01:03:21 +03:00
Author
Owner

@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, including List.

If that doesn't help you, please provide some more detailed clarification.

<!-- gh-comment-id:515692458 --> @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()`](https://godoc.org/github.com/rivo/tview#Box.SetInputCapture) on every primitive, including `List`. If that doesn't help you, please provide some more detailed clarification.
Author
Owner

@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 !

<!-- gh-comment-id:515700549 --> @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 !
Author
Owner

@rivo commented on GitHub (Jul 30, 2019):

The Tab key has a function for some of the primitives. You can intercept it on the application level by returning nil but it will affect all other primitives as well. If you only want to intercept the Tab key when your List has focus, then you only do it there.

So it really depends on how local or how global your key override should be.

<!-- gh-comment-id:516301245 --> @rivo commented on GitHub (Jul 30, 2019): The `Tab` key has a function for some of the primitives. You can intercept it on the [application level](https://godoc.org/github.com/rivo/tview#Application.SetInputCapture) by returning `nil` but it will affect all other primitives as well. If you only want to intercept the `Tab` key when your `List` has focus, then you only do it there. So it really depends on how local or how global your key override should be.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#251
No description provided.