Strage ListBox::setMouseMoveSelectsRows(true) behavior


#1

Hi.

Currently tested with Win8 x64/Juce tip.

While using ListBox, I suddenly discovered that using the mousewheel to scroll would result in double scrolling (~7 items instead of ~3.5).
Debugging, I noticed that apart from the call to ViewPort::mouseWheelMove, there was an additional call to ListBox::mouseWheelMove afterwards.

Checking with the juce demo, I was able to pinpoint the behavior to setting ListBox::setMouseMoveSelectsRows(true).
I tried it both with ListBox (FontsAndTextDemo) and TableListBox (TableDemo).

Is this a bug or am I somehow misusing it?

Thanks.


#2

No… I think you’re misunderstanding that. The Viewport gets the wheel event first, but if it uses it, then it doesn’t pass it on. If it doesn’t need the event, then it does pass it on and the ListBox gets it. I can’t see a code path where the same event would be used twice.


#3

Are you sure that setting it to true doesn’t add some listener in addition?

Viewport stack trace:

ListBox stack trace:

Notice the MouseListenerList on the ListBox event.


#4

Hmm… Ok, thanks, I’ll look into that…


#5

Odd. It does use a mouse listener, and looking at the code, I don’t think that’s necessary so I’ll remove it. But… I couldn’t find any situation where it used the same mouse-wheel event twice, so I’m not sure what it is that you’re doing to trigger a problem?


#6

Try adding the line listBox->setMouseMoveSelectsRows(true); to FontsAndTextDemo and then scroll the fonts list.
You’ll notice it scrolls twice as many rows.

Same goes for table.setMouseMoveSelectsRows(true); for TableDemo.


#7

Gotcha. Thanks, will sort it out.


#8

Glad to help, thanks for the fast reply.