From 955c9fcba2a4a8b19389760bc74a59ab2173de02 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 16 Dec 2012 00:43:47 +0300 Subject: Add keyboard selection in drop down. --- src/gui/widgets/popuplist.cpp | 6 ++++-- src/gui/widgets/popuplist.h | 8 +++----- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/gui') diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index 586dd5172..3a27b78a1 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -42,7 +42,6 @@ PopupList::PopupList(DropDown *const widget, setFocusable(true); mListBox->setDistributeMousePressed(true); - mListBox->addSelectionListener(this); mScrollArea->setPosition(mPadding, mPadding); add(mScrollArea); @@ -51,6 +50,8 @@ PopupList::PopupList(DropDown *const widget, if (gui) gui->addGlobalFocusListener(this); + addKeyListener(mDropDown); + addMouseListener(this); adjustSize(); } @@ -58,6 +59,7 @@ PopupList::~PopupList() { if (gui) gui->removeGlobalFocusListener(this); + removeKeyListener(mDropDown); } void PopupList::show(int x, int y) @@ -113,7 +115,7 @@ void PopupList::adjustSize() mListBox->setWidth(getWidth() - pad2); } -void PopupList::valueChanged(const gcn::SelectionEvent& event A_UNUSED) +void PopupList::mousePressed(gcn::MouseEvent& mouseEvent) { if (mDropDown) mDropDown->updateSelection(); diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h index a74d82c20..e609b52f6 100644 --- a/src/gui/widgets/popuplist.h +++ b/src/gui/widgets/popuplist.h @@ -27,7 +27,6 @@ #include #include "guichan/focuslistener.hpp" #include -#include "guichan/selectionlistener.hpp" #include "localconsts.h" @@ -36,8 +35,7 @@ class ListBox; class ScrollArea; class PopupList final : public Popup, - public gcn::FocusListener, - public gcn::SelectionListener + public gcn::FocusListener { public: PopupList(DropDown *const widget, @@ -62,12 +60,12 @@ class PopupList final : public Popup, void adjustSize(); - void valueChanged(const gcn::SelectionEvent& event); - void focusGained(const gcn::Event& event A_UNUSED); void focusLost(const gcn::Event& event A_UNUSED); + void mousePressed(gcn::MouseEvent& mouseEvent); + private: gcn::ListModel *mListModel; ListBox *mListBox; -- cgit v1.2.3-70-g09d2