[GH-ISSUE #60] Request: Add ability to get done callback for input field in a form #44

Closed
opened 2026-03-04 01:01:22 +03:00 by kerem · 2 comments
Owner

Originally created by @mertzt89 on GitHub (Feb 20, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/60

I noticed that it is currently only possible to get the "changed" callback from an input field that is part of a form. Would it be possible to make it so that it is also possible to get a done callback?

I understand that it is necessary for the form to get a callback so that it can progress to the next field, so my thought would be that either the below snippet could be implemented to not override the "done" callback or have the done callback handler in the form perform an additional "done" callback after it does it's handling.

github.com/rivo/tview@aea500559b/inputfield.go (L170-L173)

Originally created by @mertzt89 on GitHub (Feb 20, 2018). Original GitHub issue: https://github.com/rivo/tview/issues/60 I noticed that it is currently only possible to get the "changed" callback from an input field that is part of a form. Would it be possible to make it so that it is also possible to get a done callback? I understand that it is necessary for the form to get a callback so that it can progress to the next field, so my thought would be that either the below snippet could be implemented to not override the "done" callback or have the done callback handler in the form perform an additional "done" callback after it does it's handling. https://github.com/rivo/tview/blob/aea500559bc4bac320c43f380eb7451e3a72a0b7/inputfield.go#L170-L173
kerem closed this issue 2026-03-04 01:01:22 +03:00
Author
Owner

@rivo commented on GitHub (Feb 21, 2018):

I guess the way to achieve this now would be to capture the input field's input with SetInputCapture(). The four keys the done callback is called for are tcell.KeyEnter, tcell.KeyTab, tcell.KeyBacktab, tcell.KeyEscape.

I know this is not the exact solution you're proposing but like that, you wouldn't have to wait for me to fix this. (And it should probably be fixed in all FormItem's.)

What do you think about this?

<!-- gh-comment-id:367379882 --> @rivo commented on GitHub (Feb 21, 2018): I guess the way to achieve this now would be to capture the input field's input with [`SetInputCapture()`](https://godoc.org/github.com/rivo/tview#Box.SetInputCapture). The four keys the `done` callback is called for are `tcell.KeyEnter`, `tcell.KeyTab`, `tcell.KeyBacktab`, `tcell.KeyEscape`. I know this is not the exact solution you're proposing but like that, you wouldn't have to wait for me to fix this. (And it should probably be fixed in all `FormItem`'s.) What do you think about this?
Author
Owner

@mertzt89 commented on GitHub (Feb 21, 2018):

I just tested your suggestion and it suits my needs. Thanks!

<!-- gh-comment-id:367395925 --> @mertzt89 commented on GitHub (Feb 21, 2018): I just tested your suggestion and it suits my needs. Thanks!
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#44
No description provided.