mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 13:25:51 +03:00
[GH-ISSUE #144] How to manage form items focus change? #114
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#114
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 @stephencheng on GitHub (Jul 27, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/144
I have got mixed of input field and dropdown items, plus a ok and cancel buttons.
When I use my own selected like this:
Then I found it somehow changes the behaviour of auto focus change order. It either just stop working when you type Tab key or back Tab, or it jumps to cancel button, and skip itself in the first loop cycle of focus change when you keep press Tab. It restores the order in the second loop of focus change. Similarly the behaviour of pressing back Tab to switch focus change is disturbed too.
Is this expected?
Also with above implementation, I could simply type enter for each form item, eg dropdown or inputfield, but I couldn't do the same for the last input item because each item will require previous item being created prior to SetFocus(aCreatedItem). I can't create a button and associate the selected func with it until I use the form.AddButton to create it and add the selected func, because that function requires the reference of last input item to get value. It's sort of cyclic loop.
So is there a feature/way to auto jump to next form item without putting my own code ? or I missed something here?
Thanks
@rivo commented on GitHub (Jul 27, 2018):
Regarding the first part, are you sure you're not interfering with the form's behaviour in other places? I have trouble seeing a connection between the
selectedattribute of aDropDownand the form overall. Can you send more code that illustrates what you're doing? (Preferably a short code snippet that I can run.)Regarding the second part, there's no "auto jump" for items except the Tab key. I'm not sure why you would want to skip the Tab key in the first place. But I don't really understand what you're trying to do anyway and at what point the existing functionality of
Formis insufficient to you.@stephencheng commented on GitHub (Aug 8, 2018):
Thanks.
I think the feature I liked would mess up things around. I will probably just use tab key to shift the focus around.
@stephane-martin commented on GitHub (Apr 19, 2019):
Got a similar problem.
I have a form with a few input fields and a Confirm button. When the user selects the Confirm button, some validation stuff happens (the kind of validation that can not be dealt with an acceptance func).
For example, there is a URL input field. When the user confirms, it checks that the URL field indeed contains a well-formed URL. If it is validated, close the form and proceed. If it not validated, it shifts the focus back to the URL field so that the user can fix it (using
application.SetFocus(urlInputField).The problem is that, after fixing the URL, when the user hits TAB to navigate to the confirm button again, the form seems to believe the focus is still on the Confirm button, so the focus then goes to the wrong field.
@rivo commented on GitHub (Aug 29, 2019):
I know this comes very late. But the latest commit should fix your issue.
@stephane-martin commented on GitHub (Aug 29, 2019):
Never too late :o) Thank you