v0.7 listbox auto scrolling

Started by starkhorn, 12 September 2015, 04:00:03

starkhorn

Hi Texus,

In a chatbox, when I add a new line, if it is larger than the size of the chatbox, it automatically scrolls down.
However in a listbox, I do not get the same behaviour when I add a new item. I get the scrollbar fine and I can manually scroll up and down which is great.
Basically I want to use the listbox functionality of being able to select each line and call functions when a particular line is clicked. However I also want the chatbox functionality of autoscrolling when a new item is added.

Is there any flag on a listbox to enable this same behaviour?

starkhorn

Hey Texus,

Just wondering if you had a chance to look at this question ? I know you are busy so no worries if you need more time etc.

texus

#2
I'm sorry for not answering, I missed this topic because I didn't get a mail for it. The forum apparently doesn't send multiple mails when multiple topics are created in the same category (so I only saw the other topic that was posted that night), and since the topic was still unread it didn't send a mail on your second post either. (edit: there is an account setting for this apparently, I've changed it so this won't happen again to me)

There is no option to auto-scroll currently, but it can be done manually. Every time you add a line you can call "listBox->setSelectedItemByIndex(listBox->getItemCount() - 1)" then the scrollbar should move to the end. If the line shouldn't be selected then you could call listBox->deselectItem() right after it.

But I'll add a setAutoScroll function in v0.7-alpha2, I'll probably even make it scroll by default so that you don't even have to call anything.

starkhorn

No worries at all and thanks for the help once again.

Quote from: texus on 16 September 2015, 14:08:30
But I'll add a setAutoScroll function in v0.7-alpha2, I'll probably even make it scroll by default so that you don't even have to call anything.

Yeah this would be a great idea - perhaps with a method to disable auto-scrolling as well?

texus

The function would take a boolean as parameter, so you would disable it with setAutoScroll(false).