From 53f2f59ade349bd404672ee3a5a06f1289afa190 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 5 Oct 2013 13:18:04 +0300 Subject: Allow scroll listboxes and popup list by holding and moving mouse. --- src/gui/widgets/popuplist.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/gui/widgets/popuplist.cpp') 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) -- cgit v1.2.3-70-g09d2