From: Mikko Rasa Date: Fri, 6 Mar 2015 00:03:51 +0000 (+0200) Subject: Clear dropdown text if the associated list selection is cleared X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=9dbdf5decfa160df15c237887fdcbf12fc8f835b;p=libs%2Fgltk.git 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. --- 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