diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-05-08 11:22:54 +0200 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-05-08 11:24:52 +0200 |
commit | 0bb7c5a3a136cce0c76446dea79ce24399b21711 (patch) | |
tree | 6ccdf9279dfa05dee814b4acd3d7b77c2de360f4 | |
parent | c66b4a56badc75fbd106e2a7019b6cb83972d677 (diff) | |
download | mana-client-0bb7c5a3a136cce0c76446dea79ce24399b21711.tar.gz mana-client-0bb7c5a3a136cce0c76446dea79ce24399b21711.tar.bz2 mana-client-0bb7c5a3a136cce0c76446dea79ce24399b21711.tar.xz mana-client-0bb7c5a3a136cce0c76446dea79ce24399b21711.zip |
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.
-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()); } |