rivo / tview

Terminal UI library with rich, interactive widgets — written in Golang
MIT License
11.13k stars 575 forks source link

InputField in Form: Cursor is at the beginning of InputField and not movable when initial text is set #915

Closed elsni closed 1 year ago

elsni commented 1 year ago

When I show a form contraining an InputField with some text, the cursor is at the beginning of the InputField an can't be moved by the arrow keys. You need to type "arrow up" first, then the cursor can be moved as expected. I would expect that the cursor is at the end of the preset text, so it can be edited easily.

This is the code:

func TestForm() {
    app := tview.NewApplication()
    form := tview.NewForm().
        AddInputField("Name", "Test", 40, nil, nil)
    form.AddButton("Quit", func() {
        app.Stop()
    })
    form.SetRect(0, 0, 56, 6)
    if err := app.SetRoot(form, false).SetFocus(form).EnableMouse(true).Run(); err != nil {
        panic(err)
    }
}
rivo commented 1 year ago

Thanks for reporting this. The latest commit should fix this, i.e. the cursor will be initialized to be at the end of the text.