mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #465] Nil InputHandler doesn't skip custom form element #336
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#336
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 @tsak on GitHub (Jul 7, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/465
Hiya,
@rivo I absolutely love your library. Building command line interfaces with it is quite fun.
I'm currently building an interface for a user shell replacement, part of which is a form for network settings.
In order to make it more usable, I added a custom form element
FormHeader(see this gist for code).I'm using the following
InputHandler, naively assuming that by usingWrapInputHandler(nil)aFormHeaderwould be skipped when tabbing through the form.Unfortunately, it doesn't and I'm wondering if there was a better way to put skipable elements into a form. This touches lightly on #192 as I am also planning to disable parts of the form if DHCP is enabled, but still want to show a network interface's address.
Thanks,
tsak
@gnojus commented on GitHub (Jul 9, 2020):
Hi,
if you don't want to handle input, you shouldn't need an input handler at all. Instead I would recommend to instantly pass to next form item when
FormHeaderreceives focus. Something like this:@gnojus commented on GitHub (Jul 9, 2020):
I realized that my suggested fix will only pass focus downwards, even when pressing backtab on the form. With the current implementation of
tviewI can't come up with a nice solution, because the key events cannot be intercepted higher up than the form item, only at application level. The only way to solve this that comes to my mind is to catch the tabs/backtabs on the app level and inform all theFormHeader's to act accordingly in case they receive focus.@tsak commented on GitHub (Jul 9, 2020):
@nojus297 thank you so much for your great suggestion. I might be able to hack around the
SHIFT+TABsituation by tracking which field had focus before and store pointers in theFormHeaderitself.Thanks again for your help. It pointed me the right direction.
@rivo commented on GitHub (Jul 12, 2020):
I have planned to change this behaviour. See #421. Hopefully soon.
@gnojus commented on GitHub (Jul 12, 2020):
Just to add to this, on my fork I have changed this behavior so that all child-parent line of primitives are considered to have focus, but application knows only about the top one and passes key events to that. The primitives are responsible to pass down the key events (or intercept) to their focused children. This was done before mouse was introduced to
tviewthough.@rivo commented on GitHub (Aug 18, 2020):
Just as a heads up, keyboard events are now propagated down the hierarchy. They can be intercepted somewhere along the line.