From 9dbdf5decfa160df15c237887fdcbf12fc8f835b Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 6 Mar 2015 02:03:51 +0200 Subject: [PATCH] Clear dropdown text if the associated list selection is cleared This is currently impossible to do by interacting with the widget, but may happen if the selected item is removed. --- source/dropdown.cpp | 6 ++++++ source/dropdown.h | 1 + 2 files changed, 7 insertions(+) diff --git a/source/dropdown.cpp b/source/dropdown.cpp index 5b1d19b..34ca178 100644 --- a/source/dropdown.cpp +++ b/source/dropdown.cpp @@ -31,6 +31,7 @@ void Dropdown::init() list.set_visible(false); list.set_view_all(); list.signal_item_selected.connect(sigc::mem_fun(this, &Dropdown::list_item_selected)); + list.signal_selection_cleared.connect(sigc::mem_fun(this, &Dropdown::list_selection_cleared)); list.signal_autosize_changed.connect(sigc::mem_fun(this, &Dropdown::list_autosize_changed)); } @@ -167,6 +168,11 @@ void Dropdown::list_item_selected(unsigned index) rebuild(); } +void Dropdown::list_selection_cleared() +{ + text.set(string()); +} + Dropdown::Loader::Loader(Dropdown &d): DataFile::DerivedObjectLoader(d) diff --git a/source/dropdown.h b/source/dropdown.h index ad8b461..78c52b7 100644 --- a/source/dropdown.h +++ b/source/dropdown.h @@ -65,6 +65,7 @@ private: void list_autosize_changed(); void resize_list(); void list_item_selected(unsigned); + void list_selection_cleared(); }; } // namespace GLtk -- 2.43.0