summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-08 11:22:54 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-08 11:24:52 +0200
commit0bb7c5a3a136cce0c76446dea79ce24399b21711 (patch)
tree6ccdf9279dfa05dee814b4acd3d7b77c2de360f4 /src
parentc66b4a56badc75fbd106e2a7019b6cb83972d677 (diff)
downloadmana-0bb7c5a3a136cce0c76446dea79ce24399b21711.tar.gz
mana-0bb7c5a3a136cce0c76446dea79ce24399b21711.tar.bz2
mana-0bb7c5a3a136cce0c76446dea79ce24399b21711.tar.xz
mana-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.
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/listbox.cpp9
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());
}