From cb2263213fea95d144f939ff4d69ae1776f542a5 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 1 Nov 2011 13:51:52 +0100 Subject: Make new characters correctly appear when pos is not end=of-string. --- plugingui/lineedit.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'plugingui/lineedit.cc') diff --git a/plugingui/lineedit.cc b/plugingui/lineedit.cc index 510c551..e2a63d9 100644 --- a/plugingui/lineedit.cc +++ b/plugingui/lineedit.cc @@ -31,6 +31,8 @@ #include "painter.h" #include "globalcontext.h" +using namespace DGGUI; + #define BORDER 10 LineEdit::LineEdit(GlobalContext *gctx, Widget *parent) @@ -77,7 +79,9 @@ void LineEdit::key(KeyEvent *e) } } else if(e->keycode >= 10 && e->keycode <= 61) { - _text += e->text; + std::string pre = _text.substr(0, pos); + std::string post = _text.substr(pos, std::string::npos); + _text = pre + e->text + post; pos++; } -- cgit v1.2.3