diff options
Diffstat (limited to 'src/gui/widgets/listbox.cpp')
-rw-r--r-- | src/gui/widgets/listbox.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 8d945180a..a31947e39 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -48,6 +48,7 @@ ListBox::ListBox(const Widget2 *const widget, mForegroundSelectedColor2(getThemeColor(Theme::LISTBOX_SELECTED_OUTLINE)), mOldSelected(-1), mPadding(0), + mPressedIndex(-2), mSkin(nullptr), mDistributeMousePressed(true), mCenterText(false) @@ -204,8 +205,16 @@ void ListBox::mouseWheelMovedDown(gcn::MouseEvent &mouseEvent A_UNUSED) { } +void ListBox::mousePressed(gcn::MouseEvent &event) +{ + mPressedIndex = getSelectionByMouse(event.getY()); +} + void ListBox::mouseReleased(gcn::MouseEvent &event) { + if (mPressedIndex != getSelectionByMouse(event.getY())) + return; + if (mDistributeMousePressed) { mouseReleased1(event); @@ -233,6 +242,7 @@ void ListBox::mouseReleased(gcn::MouseEvent &event) break; } } + mPressedIndex = -2; } void ListBox::mouseReleased1(gcn::MouseEvent &mouseEvent) @@ -281,5 +291,7 @@ void ListBox::logic() int ListBox::getSelectionByMouse(const int y) const { + if (y < mPadding) + return -1; return (y - mPadding) / getRowHeight(); } |