From 0bb7c5a3a136cce0c76446dea79ce24399b21711 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 8 May 2009 11:22:54 +0200 Subject: Fixed list box selection wrapping to the bottom on dragging upwards Negative values of y were not handled correctly, causing the selection to wrap when the mouse moved out of the listbox at the top while dragging. --- src/gui/widgets/listbox.cpp | 9 ++++++--- 1 file 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()); } -- cgit v1.2.3-70-g09d2