ListBox and mouse wheel issue

If ListBox::viewport scrollbars are not displayed, mouseWheelMove events are not forwarded to parent.

To fix this issue, I have change this code:

void ListBox::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) { getHorizontalScrollBar()->mouseWheelMove (e, wheelIncrementX, 0); getVerticalScrollBar()->mouseWheelMove (e, 0, wheelIncrementY); }

To this one:

void ListBox::mouseWheelMove (const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) { ScrollBar* hScroolBar = viewport->getHorizontalScrollBar(); ScrollBar* vScroolBar = viewport->getVerticalScrollBar(); if (hScroolBar->isVisible() || vScroolBar->isVisible()) { hScroolBar->mouseWheelMove (e, wheelIncrementX, 0); vScroolBar->mouseWheelMove (e, 0, wheelIncrementY); } else // if no viewport scrollbars, forward mouseWheel event to parent. return Component::mouseWheelMove (e, wheelIncrementX, wheelIncrementY); }

This fix can be useful when Viewport children contain ListBox components.
I hope my first post can help.

on a related note, i’ve found the following bug related to mousewheel after resizing a listbox.

  1. Have a listbox with visible scrollbars (i.e. at least one-too-many items to fit)
  2. Resize the listbox so that all items now fit (and the scrollbars disappear)
  3. Move the mousewheel, and notice that a vertical scrollbar has now appeared with inappropriate bounds

You can reproduce it with the jucedemo, on the TableComponents page - although it’d probably be tricky to make the window big enough if you’re running at a low resolution :slight_smile:

Thanks chaps, I’ll take a look at those issues right away!