Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create autoscroll for listbox #318

Open
catarium opened this issue Jun 3, 2021 · 4 comments
Open

Create autoscroll for listbox #318

catarium opened this issue Jun 3, 2021 · 4 comments

Comments

@catarium
Copy link

catarium commented Jun 3, 2021

Listbox autoscrolling if scrollbar is at the bottom.
Example:
https://user-images.githubusercontent.com/60063501/120595827-aa149900-c44b-11eb-9b66-c90f57678208.mp4

@peterbrittain
Copy link
Owner

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?

@catarium
Copy link
Author

catarium commented Jun 3, 2021

@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

@peterbrittain
Copy link
Owner

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?

@catarium
Copy link
Author

catarium commented Jun 5, 2021

May create a flag that will execute such code

ListBox.autoscroll = True

or

ListBox.set_autoscroll(True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants