[GH-ISSUE #360] Modal buttons: Reset to buttonIndex = 0 ? #269

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

Originally created by @triddell on GitHub (Oct 30, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/360

Thanks for tview! I'm now getting back into a project I worked on months back and am very much enjoying this library once again. However, I have an issue that I can't seem to get past.

I'm implementing a modal dialog with text like Warning: Bad things may happen... are you very sure you want to continue? And the buttons would read No way! and Of course, I've got this!

However, the modal dialog is remembering the last selected button index! So if on one attempt, Of course, I've got this! is chosen, then the next time the modal dialog is shown, Of course, I've got this! is the default value! And with only two buttons displayed, it's hard for the end user to know which button is actually highlighted.

Is there a way to reset the buttonIndex to 0 when redisplaying a model dialog? I believe you added form.SetFocus(0) support to forms for a somewhat similar issue.

Originally created by @triddell on GitHub (Oct 30, 2019). Original GitHub issue: https://github.com/rivo/tview/issues/360 Thanks for tview! I'm now getting back into a project I worked on months back and am very much enjoying this library once again. However, I have an issue that I can't seem to get past. I'm implementing a modal dialog with text like `Warning: Bad things may happen... are you very sure you want to continue?` And the buttons would read `No way!` and `Of course, I've got this!` However, the modal dialog is remembering the last selected button index! So if on one attempt, `Of course, I've got this!` is chosen, then the next time the modal dialog is shown, `Of course, I've got this!` is the default value! And with only two buttons displayed, it's hard for the end user to know which button is actually highlighted. Is there a way to reset the buttonIndex to 0 when redisplaying a model dialog? I believe you added `form.SetFocus(0)` support to forms for a somewhat similar issue.
kerem closed this issue 2026-03-04 01:03:30 +03:00
Author
Owner

@millerlogic commented on GitHub (Nov 4, 2019):

I'd also like to be able to set which button I want initially focused. Perhaps a SetButtonFocus(index int)?

<!-- gh-comment-id:549194829 --> @millerlogic commented on GitHub (Nov 4, 2019): I'd also like to be able to set which button I want initially focused. Perhaps a ```SetButtonFocus(index int)```?
Author
Owner

@triddell commented on GitHub (Nov 5, 2019):

I just added PR #364 which resolves this issue for me. Please accept or modify as necessary. Thanks.

<!-- gh-comment-id:550019671 --> @triddell commented on GitHub (Nov 5, 2019): I just added PR #364 which resolves this issue for me. Please accept or modify as necessary. Thanks.
Author
Owner

@rivo commented on GitHub (Nov 27, 2019):

I provided the change myself, mostly because you copy&pasted the function comment from Form which didn't make much sense in Modal's context. Anyway, this should be resolved now.

<!-- gh-comment-id:559183966 --> @rivo commented on GitHub (Nov 27, 2019): I provided the change myself, mostly because you copy&pasted the function comment from `Form` which didn't make much sense in `Modal`'s context. Anyway, this should be resolved now.
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#269
No description provided.