rivo / tview

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

[QUESTION] Optionally limiting height of dropdown to height of form where dropdown is defined? #813

Closed twilight-roadrunner closed 1 year ago

twilight-roadrunner commented 1 year ago

Is it possible to limit the height of a TView dropdown list such that its height will not exceed the borders of a form in which the dropdown has been defined?

A very cursory examination of the "dropdown.go" module would seem to suggest the height of a dropdown list is governed only by the size of the TCell screen upon which the form is being displayed. For long dropdown lists, this results in the borders of the form being exceeded and, in the case where the form is being displayed in a GO Winman window that is smaller than the screen size, causes any dropdown list content that would exist outside of the window border to not be visible.

Is there some technique when using TView dropdowns that can be employed to avoid this?

Many thanks for your time.

rivo commented 1 year ago

A drop-down list is meant to be opened only temporarily, to select the value of the drop-down element. So, yes, it can exceed the borders of the form it is contained in. I don't (yet?) see a reason why it should be constrained to the form's box, especially considering that some forms can be quite small.

I don't know "GO Winman" so I don't know how it relates to tview. But generally, if a tview application is contained in some window that doesn't display all of its contents, then I think you have to accept that some of it will not be visible.

As a possible solution, though, if you know in advance how large the visible area will be, you can use your own tcell.Screen object and use SetScreen() to force the application to use it. This might come with other drawbacks but it may just be ok for you.

rivo commented 1 year ago

Closing this as it looks solved to me.