From: Mikko Rasa Date: Tue, 22 Jul 2008 17:56:07 +0000 (+0000) Subject: Render text in Dropdown directly from the List X-Git-Tag: 0.9~3 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d7274749cb0e171e59d7dc9d7d1712906a351119;p=libs%2Fgltk.git Render text in Dropdown directly from the List Don't add control characters to Entry's buffer --- diff --git a/source/dropdown.cpp b/source/dropdown.cpp index b25e594..5d8a547 100644 --- a/source/dropdown.cpp +++ b/source/dropdown.cpp @@ -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; diff --git a/source/dropdown.h b/source/dropdown.h index c9291f9..1ff69be 100644 --- a/source/dropdown.h +++ b/source/dropdown.h @@ -29,7 +29,6 @@ public: private: List *list; - std::string text; bool dropped; bool list_active; diff --git a/source/entry.cpp b/source/entry.cpp index efb4b45..7f50ed0 100644 --- a/source/entry.cpp +++ b/source/entry.cpp @@ -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::ustring(1, ch))); ++edit_pos;