diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-04-03 20:41:04 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-04-03 20:41:04 +0300 |
commit | 855947baec01a77f18c8c3cee8c0af000131b71e (patch) | |
tree | 323a8589bcefdc6f400065a68dce297f7cda2467 /src/gui/widgets | |
parent | 2947d6af4334a736eab6ea1ad8147239311ea027 (diff) | |
download | manaplus-855947baec01a77f18c8c3cee8c0af000131b71e.tar.gz manaplus-855947baec01a77f18c8c3cee8c0af000131b71e.tar.bz2 manaplus-855947baec01a77f18c8c3cee8c0af000131b71e.tar.xz manaplus-855947baec01a77f18c8c3cee8c0af000131b71e.zip |
Fix close dropdowns on item selection.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/listbox.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/popuplist.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/widget.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/widget.h | 10 |
5 files changed, 17 insertions, 5 deletions
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index c41e32854..341204505 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -275,7 +275,7 @@ void ListBox::mouseWheelMovedDown(MouseEvent &event A_UNUSED) void ListBox::mousePressed(MouseEvent &event) { mPressedIndex = getSelectionByMouse(event.getY()); - if (mPressedIndex != -1) + if (mMouseConsume && mPressedIndex != -1) event.consume(); } diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index fa0616fd2..c203f59c6 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -43,6 +43,8 @@ PopupList::PopupList(DropDown *const widget, mModal(modal) { mListBox->postInit(); + mListBox->setMouseConsume(false); + mScrollArea->setMouseConsume(false); mAllowLogic = false; setFocusable(true); diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 2efa144c9..95a9cd399 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -866,7 +866,7 @@ void ScrollArea::mouseReleased(MouseEvent& event) } mClickX = 0; mClickY = 0; - if (dx || dy) + if (mMouseConsume && (dx || dy)) event.consume(); } } @@ -876,7 +876,8 @@ void ScrollArea::mouseReleased(MouseEvent& event) mRightButtonPressed = false; mIsHorizontalMarkerDragged = false; mIsVerticalMarkerDragged = false; - event.consume(); + if (mMouseConsume) + event.consume(); mRedraw = true; } diff --git a/src/gui/widgets/widget.cpp b/src/gui/widgets/widget.cpp index aa3e6254b..c61881673 100644 --- a/src/gui/widgets/widget.cpp +++ b/src/gui/widgets/widget.cpp @@ -107,7 +107,8 @@ Widget::Widget(const Widget2 *const widget) : mTabIn(true), mTabOut(true), mEnabled(true), - mAllowLogic(true) + mAllowLogic(true), + mMouseConsume(true) { mWidgets.push_back(this); mWidgetsSet.insert(this); diff --git a/src/gui/widgets/widget.h b/src/gui/widgets/widget.h index 236c7b6ee..86b203666 100644 --- a/src/gui/widgets/widget.h +++ b/src/gui/widgets/widget.h @@ -1009,9 +1009,15 @@ class Widget : public Widget2 */ virtual void showPart(const Rect &rectangle); - bool isAllowLogic() const + bool isAllowLogic() const A_WARN_UNUSED { return mAllowLogic; } + void setMouseConsume(const bool b) + { mMouseConsume = b; } + + bool isMouseConsume() const A_WARN_UNUSED + { return mMouseConsume; } + protected: /** * Distributes an action event to all action listeners @@ -1222,6 +1228,8 @@ class Widget : public Widget2 bool mAllowLogic; + bool mMouseConsume; + /** * Holds the global font used by the widget. */ |