I may simply be doing this wrong. I am using an InputField to implement a command prompt of sorts (e.g. IRC command and message entry). In the InputField's DoneFunc, I am doing this...
case tcell.KeyEnter:
defer cmdLine.SetText("")
So that regardless of what happens next with the value of the existing text, enter will "clear" the text of the input field to be ready for a new command. This causes a panic as soon as you begin to type some other character after SetText("").
https://github.com/rivo/tview/blob/master/inputfield.go#L365
newText := i.text[:i.cursorPos] + string(r) + i.text[i.cursorPos:]
If I remove the SetText(""), then no panic occurs, but the text remains in the input field. I can hold the delete/backspace key to clear the text and type something else in its place without panic.
Is there a better approach to what I am doing?
I may simply be doing this wrong. I am using an InputField to implement a command prompt of sorts (e.g. IRC command and message entry). In the InputField's DoneFunc, I am doing this...
So that regardless of what happens next with the value of the existing text, enter will "clear" the text of the input field to be ready for a new command. This causes a panic as soon as you begin to type some other character after SetText("").
https://github.com/rivo/tview/blob/master/inputfield.go#L365
newText := i.text[:i.cursorPos] + string(r) + i.text[i.cursorPos:]If I remove the SetText(""), then no panic occurs, but the text remains in the input field. I can hold the delete/backspace key to clear the text and type something else in its place without panic.
Is there a better approach to what I am doing?