[GH-ISSUE #55] Quick silly question #40

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

Originally created by @ghost on GitHub (Feb 9, 2018).
Original GitHub issue: https://github.com/rivo/tview/issues/55

Oh what the heck. Sorry for the silly question, but if you can find a minute to answer I would really appreciate it:

It's not at all obvious to me how to get the value the user inputs for the Name input field, in below simple snippet. Can some please put me out of my misery?

https://stackoverflow.com/questions/48715418/getting-the-actual-form-values-when-using-tivo-tview-golang-library

Originally created by @ghost on GitHub (Feb 9, 2018). Original GitHub issue: https://github.com/rivo/tview/issues/55 Oh what the heck. Sorry for the silly question, but if you can find a minute to answer I would really appreciate it: It's not at all obvious to me how to get the value the user inputs for the Name input field, in below simple snippet. Can some please put me out of my misery? https://stackoverflow.com/questions/48715418/getting-the-actual-form-values-when-using-tivo-tview-golang-library
kerem closed this issue 2026-03-04 01:01:20 +03:00
Author
Owner

@ghost commented on GitHub (Feb 10, 2018):

Nevermind. The StackOverflow questions was answered.

fmt.Printf("%s\n", form.GetFormItem(0).(*tview.InputField).GetText() )

Thanks

<!-- gh-comment-id:364624725 --> @ghost commented on GitHub (Feb 10, 2018): Nevermind. The StackOverflow questions was answered. `fmt.Printf("%s\n", form.GetFormItem(0).(*tview.InputField).GetText() )` Thanks
Author
Owner

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

Not a silly question. ;-) The Stack Overflow answer is correct. And I'll add that instead of reading out the text at the end, I usually register all changes to an input field:

form.AddInputField("Text:", "", 0, nil, func(text string) {
  myText = text
})
// ...
fmt.Println(myText)

In this solution, you don't need to cast or know the index of the input field.

<!-- gh-comment-id:364647713 --> @rivo commented on GitHub (Feb 10, 2018): Not a silly question. ;-) The Stack Overflow answer is correct. And I'll add that instead of reading out the text at the end, I usually register all changes to an input field: ```go form.AddInputField("Text:", "", 0, nil, func(text string) { myText = text }) // ... fmt.Println(myText) ``` In this solution, you don't need to cast or know the index of the input field.
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#40
No description provided.