diff options
-rw-r--r-- | src/gui/widgets/listbox.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 28a5a018..e9c3f882 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -116,7 +116,10 @@ void ListBox::mouseWheelMovedDown(gcn::MouseEvent& mouseEvent) void ListBox::mouseDragged(gcn::MouseEvent &event) { - // Pretend mouse is pressed continuously while dragged. Causes list - // selection to be updated as is default in many GUIs. - mousePressed(event); + if (event.getButton() != gcn::MouseEvent::LEFT) + return; + + // Make list selection update on drag, but guard against negative y + int y = std::max(0, event.getY()); + setSelected(y / getRowHeight()); } |