X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fentry.cpp;h=8aee0cf4962ee3ed6a4994a045c622a4631d153a;hb=022c6ccec48b5dca482239da4a4c38550377b188;hp=52a7b429d269e0013e71c44d7d918a9a8dca55b5;hpb=43a75e4e9be56c58be5e224f19016bb14b56a7ef;p=libs%2Fgltk.git diff --git a/source/entry.cpp b/source/entry.cpp index 52a7b42..8aee0cf 100644 --- a/source/entry.cpp +++ b/source/entry.cpp @@ -20,7 +20,8 @@ Entry::Entry(const string &t): first_row(0), visible_rows(1), text_part(0), - slider(0) + slider(0), + got_key_press(false) { set_text(t); } @@ -145,6 +146,7 @@ void Entry::render_special(const Part &part, GL::Renderer &renderer) const void Entry::key_press(unsigned key, unsigned) { + got_key_press = true; if(key==Input::KEY_LEFT) { if(edit_pos>0) @@ -191,7 +193,7 @@ void Entry::key_press(unsigned key, unsigned) void Entry::character(wchar_t ch) { - if(ch>=' ') + if(got_key_press && ch>=' ') { text.insert(edit_pos, StringCodec::encode(StringCodec::ustring(1, ch))); ++edit_pos; @@ -199,6 +201,12 @@ void Entry::character(wchar_t ch) } } +void Entry::focus_out() +{ + Widget::focus_out(); + got_key_press = false; +} + void Entry::on_geometry_change() { reposition_slider();