summaryrefslogtreecommitdiff
path: root/src/gui/widgets/popuplist.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets/popuplist.cpp')
-rw-r--r--src/gui/widgets/popuplist.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp
index 2d32a5490..5fd38a785 100644
--- a/src/gui/widgets/popuplist.cpp
+++ b/src/gui/widgets/popuplist.cpp
@@ -39,6 +39,7 @@ PopupList::PopupList(DropDown *const widget,
new ListBox(widget, listModel, "popuplistbox.xml")),
mScrollArea(new ScrollArea(mListBox, false)),
mDropDown(widget),
+ mPressedIndex(-2),
mModal(modal)
{
setFocusable(true);
@@ -122,8 +123,22 @@ void PopupList::adjustSize()
mListBox->setWidth(width);
}
+void PopupList::mousePressed(gcn::MouseEvent& mouseEvent)
+{
+ mPressedIndex = mListBox->getSelectionByMouse(
+ mouseEvent.getY() + mPadding);
+}
+
void PopupList::mouseReleased(gcn::MouseEvent& mouseEvent)
{
+ if (mPressedIndex != mListBox->getSelectionByMouse(
+ mouseEvent.getY() + mPadding))
+ {
+ mPressedIndex = -2;
+ return;
+ }
+
+ mPressedIndex = -2;
if (mouseEvent.getSource() == mScrollArea)
return;
if (mDropDown)