diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/npcdialog.cpp | 1 | ||||
-rw-r--r-- | src/gui/widgets/listbox.cpp | 11 | ||||
-rw-r--r-- | src/gui/widgets/listbox.h | 6 |
3 files changed, 17 insertions, 1 deletions
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index e67213bd8..ec33f3f0d 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -96,6 +96,7 @@ NpcDialog::NpcDialog(int npcId) : mItemList->setWrappingEnabled(true); mItemList->setActionEventId("ok"); mItemList->addActionListener(this); + mItemList->setDistributeMousePressed(false); setContentSize(260, 175); diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 267f2c8cc..949efe05d 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -42,7 +42,8 @@ float ListBox::mAlpha = 1.0; ListBox::ListBox(gcn::ListModel *listModel): - gcn::ListBox(listModel) + gcn::ListBox(listModel), + mDistributeMousePressed(true) { mHighlightColor = Theme::getThemeColor(Theme::HIGHLIGHT); setForegroundColor(Theme::getThemeColor(Theme::TEXT)); @@ -142,6 +143,14 @@ void ListBox::mouseWheelMovedDown(gcn::MouseEvent &mouseEvent A_UNUSED) { } +void ListBox::mousePressed(gcn::MouseEvent &event) +{ + if (mDistributeMousePressed) + distributeActionEvent(); + else + mouseDragged(event); +} + void ListBox::mouseDragged(gcn::MouseEvent &event) { if (event.getButton() != gcn::MouseEvent::LEFT || getRowHeight() == 0) diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 1df07f19d..b02357752 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -64,12 +64,18 @@ class ListBox : public gcn::ListBox void mouseWheelMovedDown(gcn::MouseEvent& mouseEvent); + void mousePressed(gcn::MouseEvent &event); + void mouseDragged(gcn::MouseEvent &event); void refocus(); + void setDistributeMousePressed(bool b) + { mDistributeMousePressed = b; } + protected: gcn::Color mHighlightColor; + bool mDistributeMousePressed; static float mAlpha; }; |