]> git.tdb.fi Git - libs/gltk.git/commitdiff
Render text in Dropdown directly from the List
authorMikko Rasa <tdb@tdb.fi>
Tue, 22 Jul 2008 17:56:07 +0000 (17:56 +0000)
committerMikko Rasa <tdb@tdb.fi>
Tue, 22 Jul 2008 17:56:07 +0000 (17:56 +0000)
Don't add control characters to Entry's buffer

source/dropdown.cpp
source/dropdown.h
source/entry.cpp

index b25e5944d2548241e534bf78071d37dde44960c7..5d8a547bebae925083fb40222e8dde20f8178ab2 100644 (file)
@@ -115,7 +115,10 @@ void Dropdown::pointer_motion(int x, int y)
 void Dropdown::render_special(const Part &part) const
 {
        if(part.get_name()=="text")
-               render_text(part, text);
+       {
+               if(list->get_selected_index()>=0)
+                       render_text(part, list->get_selected());
+       }
        else if(part.get_name()=="list" && dropped)
                list->render();
 }
@@ -127,8 +130,6 @@ void Dropdown::on_geometry_change()
 
 void Dropdown::list_item_selected(unsigned index, const std::string &item)
 {
-       text=item;
-
        if(dropped)
        {
                list_active=false;
index c9291f91e8d8c39929d0eca0b3bb829ca8e449a2..1ff69be7c6150354983a736e64496b2e389f33fb 100644 (file)
@@ -29,7 +29,6 @@ public:
 
 private:
        List *list;
-       std::string text;
        bool dropped;
        bool list_active;
 
index efb4b45c57d354ca4f11b453ff567fe58d108421..7f50ed038fbdd6cc4a758adcc0973d84f550b726 100644 (file)
@@ -52,7 +52,7 @@ void Entry::key_press(unsigned key, unsigned, wchar_t ch)
                if(edit_pos>0)
                        text.erase(--edit_pos, 1);
        }
-       else
+       else if(ch>=' ')
        {
                text.insert(edit_pos, Codecs::encode<Codecs::Utf8>(Codecs::ustring(1, ch)));
                ++edit_pos;