]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/dropdown.cpp
Add List::set_selected_index
[libs/gltk.git] / source / dropdown.cpp
index 4d18187a7fb28642934dd5a5aeb0adb0038e85b6..b25e5944d2548241e534bf78071d37dde44960c7 100644 (file)
@@ -36,6 +36,36 @@ void Dropdown::append(const string &item)
        list->append(item);
 }
 
+void Dropdown::insert(unsigned i, const string &v)
+{
+       list->insert(i, v);
+}
+
+void Dropdown::remove(unsigned i)
+{
+       list->remove(i);
+}
+
+void Dropdown::clear()
+{
+       list->clear();
+}
+
+void Dropdown::set_selected_index(int i)
+{
+       list->set_selected_index(i);
+}
+
+const string &Dropdown::get_selected() const
+{
+       return list->get_selected();
+}
+
+int Dropdown::get_selected_index() const
+{
+       return list->get_selected_index();
+}
+
 void Dropdown::button_press(int x, int y, unsigned btn)
 {
        if(list->get_geometry().is_inside(x, y))
@@ -99,11 +129,14 @@ void Dropdown::list_item_selected(unsigned index, const std::string &item)
 {
        text=item;
 
-       list_active=false;
-       dropped=false;
-       state&=~ACTIVE;
-       if(parent)
-               parent->ungrab_pointer(*this);
+       if(dropped)
+       {
+               list_active=false;
+               dropped=false;
+               state&=~ACTIVE;
+               if(parent)
+                       parent->ungrab_pointer(*this);
+       }
 
        signal_item_selected.emit(index, item);
 }