mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[GH-ISSUE #421] SetInputCapture isn't fired on a parent component #307
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#307
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 @k33nice on GitHub (Mar 27, 2020).
Original GitHub issue: https://github.com/rivo/tview/issues/421
For me, it's pretty unintuitive that
SetInputCaptureisn't called if a child is focused and the event key was fired. AlsoHasFocusmethod returns true for the parent block.I've found a simple workaround. IMO it looks a bit hacky:
@rivo commented on GitHub (Mar 30, 2020):
I agree with you that this is not optimal. It was an early design decision to keep a global pointer to one element which has focus and route all keyboard input to it directly. Maybe I wasn't sure why one would want to handle some input higher up at the same time (in a
Flexin your case). TheHasFocus()function (which, also in retrospect, should not be public but that's another topic) was basically just there to indicate which element has focus (with a two-line border around it) and that wouldn't work if it applied only to leaf elements.For the newly added mouse support, we do it differently: Mouse events bubble down the tree and can be intercepted anywhere along the way. I will probably look at implementing keyboard input the same way. But I'll have to check how much this affects backwards compatibility.
For now, your workaround is probably the only way to make this work.
@rivo commented on GitHub (Aug 18, 2020):
I implemented this just now. Please let me know if it works for you as you expect.