rivo / tview

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

tview application freezes with AddTextView form component specific configuration and keystroke capture #880

Open WeBtOrY-ES opened 1 year ago

WeBtOrY-ES commented 1 year ago

Hi!

After injecting application and form as a parameters of a function tview.NewApplication(),tview.NewForm() as application *tview.Application, form *tview.Form

when you use this configuration of AddTextView

form.AddTextView("Server name", serverName, 20, 1, false, false)

and the Esc key is pressed

(captured with this code)

application.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { k := event.Key() if k == tcell.KeyEsc { escPressed = true application.Stop() } return event })

the application freezes.

However, with this configuration of AddTextView is used

form.AddTextView("Server name", serverName, 20, 1, false, true)

the application behaves as it should.

I don't know if is a expected behavior or is a bug.

digitallyserviced commented 1 year ago

@WeBtOrY-ES

This isnt really expected behavior. but this is because of the way that the Form handles it's internal widgets/fields for focusing things... It obviously shouldn't cause a deadlock/freeze... but this is probably similar to this issue

797

Basically if you choose to use the Form widget/primitive, you have to use all the methods within the Form to add/manage the internal fields/widgets.

Otherwise you can manually handle the container that has your form fields/widgets and not worry about a form container. All the Form provides is some sugar to make dealing with input containers easier for people who don't want to handle things themselves or have more control.