mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #38] Determine Primitive with the current focus? #29
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#29
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 @triddell on GitHub (Jan 19, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/38
I'm using the app.SetInputCapture() function to setup some global hot-keys similar to the screens in your presentation sample. Instead of navigating back and forward though I have numbers as the hot-keys (1, 2, 3, etc.) for the various pages. But, when I have a form where I want to allow text to be entered, I need to shortcut the hot-keys and then allow numbers to be entered.
I have a hacky way of doing this now since all of my focused (and horizontal!) forms have the same (and unique in the app) "y" value as returned from this function:
_, y, _, _ := app.GetFocus().GetRect()I'd like to do this more cleanly with the API though. Is there any way to determine the type of Primitive that has the current focus? I need to use some vertical forms in the future in different positions and this hack won't work then. If I know that a form has the current focus then I can shortcut the hot-key numbers and allow them to be entered into fields. I use a Cancel button to switch the focus off the form and then the hot-keys work again.
Thanks again for your hard work on tview! My app is progressing nicely and it is definitely fun to code!
@rivo commented on GitHub (Jan 21, 2018):
I'm doing this in my own application:
Basically, if an
InputFieldhas focus, I'm deactivating the global key handler. Would that help you in your case?@triddell commented on GitHub (Jan 23, 2018):
Yes, this worked great for me too. Thanks!