]> git.tdb.fi Git - libs/gltk.git/commitdiff
Clear dropdown text if the associated list selection is cleared
authorMikko Rasa <tdb@tdb.fi>
Fri, 6 Mar 2015 00:03:51 +0000 (02:03 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 6 Mar 2015 00:03:51 +0000 (02:03 +0200)
This is currently impossible to do by interacting with the widget, but
may happen if the selected item is removed.

source/dropdown.cpp
source/dropdown.h

index 5b1d19b4f4d6c04576e76a9a015b945b0a956a93..34ca1781153f946fddaaf69f82e993643b2864f1 100644 (file)
@@ -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<Dropdown, Widget::Loader>(d)
index ad8b4619bc4a00789e6bd53ab6ac6dae3ba83829..78c52b763a6215aab975904c02be782713628056 100644 (file)
@@ -65,6 +65,7 @@ private:
        void list_autosize_changed();
        void resize_list();
        void list_item_selected(unsigned);
+       void list_selection_cleared();
 };
 
 } // namespace GLtk