summaryrefslogtreecommitdiff
path: root/src/gui/widgets/popuplist.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-10-05 13:18:04 +0300
committerAndrei Karas <akaras@inbox.ru>2013-10-05 13:18:04 +0300
commit53f2f59ade349bd404672ee3a5a06f1289afa190 (patch)
treeca595c457181a742bbebd3f890480341c949399b /src/gui/widgets/popuplist.cpp
parent01660865a49250c6ed77159cb3d8b38e7ea37b95 (diff)
downloadplus-53f2f59ade349bd404672ee3a5a06f1289afa190.tar.gz
plus-53f2f59ade349bd404672ee3a5a06f1289afa190.tar.bz2
plus-53f2f59ade349bd404672ee3a5a06f1289afa190.tar.xz
plus-53f2f59ade349bd404672ee3a5a06f1289afa190.zip
Allow scroll listboxes and popup list by holding and moving mouse.
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)