Strage ListBox::setMouseMoveSelectsRows(true) behavior



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?



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.


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.


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


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?


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.


Gotcha. Thanks, will sort it out.


Glad to help, thanks for the fast reply.