diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-12-15 23:21:27 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-12-15 23:52:24 +0300 |
commit | 54ff2f6fec70e66d7a8b4a96b28fa7d46f2304a3 (patch) | |
tree | 4bcee0ad9757bc328bae9c0435a3a1e8d85f1676 /src/gui/widgets/popuplist.cpp | |
parent | 62a466e53cbb49c5338f8ea7f96b46e00d3b0bc4 (diff) | |
download | manaverse-54ff2f6fec70e66d7a8b4a96b28fa7d46f2304a3.tar.gz manaverse-54ff2f6fec70e66d7a8b4a96b28fa7d46f2304a3.tar.bz2 manaverse-54ff2f6fec70e66d7a8b4a96b28fa7d46f2304a3.tar.xz manaverse-54ff2f6fec70e66d7a8b4a96b28fa7d46f2304a3.zip |
Allow hide popup list if focus lost.
Diffstat (limited to 'src/gui/widgets/popuplist.cpp')
-rw-r--r-- | src/gui/widgets/popuplist.cpp | 26 |
1 files changed, 24 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); } |