summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/popuplist.cpp26
-rw-r--r--src/gui/widgets/popuplist.h4
2 files changed, 28 insertions, 2 deletions
diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp
index e32cd5b70..eb711ddeb 100644
--- a/src/gui/widgets/popuplist.cpp
+++ b/src/gui/widgets/popuplist.cpp
@@ -20,6 +20,8 @@
#include "gui/widgets/popuplist.h"
+#include "gui/gui.h"
+
#include "gui/widgets/dropdown.h"
#include "gui/widgets/listbox.h"
#include "gui/widgets/scrollarea.h"
@@ -46,6 +48,14 @@ PopupList::PopupList(DropDown *const widget,
if (getParent())
getParent()->addFocusListener(this);
+ if (gui)
+ gui->addGlobalFocusListener(this);
+}
+
+PopupList::~PopupList()
+{
+ if (gui)
+ gui->removeGlobalFocusListener(this);
}
void PopupList::show(int x, int y)
@@ -106,10 +116,22 @@ void PopupList::valueChanged(const gcn::SelectionEvent& event A_UNUSED)
setVisible(false);
}
+void PopupList::focusGained(const gcn::Event& event A_UNUSED)
+{
+ const gcn::Widget *const source = event.getSource();
+ if (source == this || source == mListBox
+ || source == mScrollArea || source == mDropDown)
+ {
+ return;
+ }
+
+ if (mDropDown)
+ mDropDown->updateSelection();
+ setVisible(false);
+}
+
void PopupList::focusLost(const gcn::Event& event A_UNUSED)
{
- logger->log("lost focus");
if (mDropDown)
mDropDown->updateSelection();
-// setVisible(false);
}
diff --git a/src/gui/widgets/popuplist.h b/src/gui/widgets/popuplist.h
index f0b195a47..a74d82c20 100644
--- a/src/gui/widgets/popuplist.h
+++ b/src/gui/widgets/popuplist.h
@@ -43,6 +43,8 @@ class PopupList final : public Popup,
PopupList(DropDown *const widget,
gcn::ListModel *const listModel);
+ ~PopupList();
+
A_DELETE_COPY(PopupList)
void show(int x, int y);
@@ -62,6 +64,8 @@ class PopupList final : public Popup,
void valueChanged(const gcn::SelectionEvent& event);
+ void focusGained(const gcn::Event& event A_UNUSED);
+
void focusLost(const gcn::Event& event A_UNUSED);
private: