Open catarium opened 3 years ago
Hi. It's not clear what you're asking for...
Looking at your video, you are clearly updating the options of a ListBox (to add a new line). When you do that, asciimatics will try to find the existing selection in the new list of options and scroll to make that visible, which is what appears to be happening here.
Can you explain what you want to change?
@peterbrittain
Ok, I'll try explain my idea by code, because my eng not good.
if ListBox.value == ListBox.options[-1][1]:
ListBox.options = new_options
ListBox.value = new_options[-1][1] # scroll to bottom of listbox
else:
ListBox.options = new_options
Ok! Got it. Thanks.
It seems to me that this code is easy to write if anyone needs it, so I'm not sure it warrants adding to the base package. Looking at equivalent GUI systems, it's pretty common that you have to write something similar to that. For example, see https://www.csharp-examples.net/autoscroll/
But maybe it would be easier to write if the selected index was exposed as a property?
May create a flag that will execute such code
ListBox.autoscroll = True
or
ListBox.set_autoscroll(True)
Listbox autoscrolling if scrollbar is at the bottom. Example: https://user-images.githubusercontent.com/60063501/120595827-aa149900-c44b-11eb-9b66-c90f57678208.mp4