diff --git a/include/nana/gui/widgets/skeletons/text_editor.hpp b/include/nana/gui/widgets/skeletons/text_editor.hpp index b4f6318d..c2050a66 100644 --- a/include/nana/gui/widgets/skeletons/text_editor.hpp +++ b/include/nana/gui/widgets/skeletons/text_editor.hpp @@ -148,7 +148,7 @@ namespace nana{ namespace widgets * @param reset indicates whether to reset the text position by the pos. If this parameter is true, the text position is set by pos. If the parameter is false, it only moves the UI caret to the specified position. */ bool move_caret(const upoint& pos, bool reset = false); - void move_caret_end(); + void move_caret_end(bool update); void reset_caret_pixels() const; void reset_caret(); void show_caret(bool isshow); diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index 28429f8f..00dd0d71 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -1797,7 +1797,7 @@ namespace nana{ namespace widgets if (select_all) { select(true); - move_caret_end(); + move_caret_end(false); renderred = true; //If the text widget is focused by clicking mouse button, the selected text will be cancelled @@ -1991,8 +1991,6 @@ namespace nana{ namespace widgets return str; } - //move_caret - //Set caret position through text coordinate bool text_editor::move_caret(const upoint& crtpos, bool reset_caret) { const unsigned line_pixels = line_height(); @@ -2036,11 +2034,14 @@ namespace nana{ namespace widgets return false; } - void text_editor::move_caret_end() + void text_editor::move_caret_end(bool update) { points_.caret.y = static_cast(impl_->textbase.lines()); if(points_.caret.y) --points_.caret.y; points_.caret.x = static_cast(impl_->textbase.getline(points_.caret.y).size()); + + if (update) + this->move_caret(points_.caret, false); } void text_editor::reset_caret_pixels() const diff --git a/source/gui/widgets/textbox.cpp b/source/gui/widgets/textbox.cpp index 2501e541..67d6436c 100644 --- a/source/gui/widgets/textbox.cpp +++ b/source/gui/widgets/textbox.cpp @@ -260,8 +260,11 @@ namespace drawerbase { internal_scope_guard lock; auto editor = get_drawer_trigger().editor(); if (editor) - { - editor->text(to_wstring(str), end_caret); + { + editor->text(to_wstring(str), false); + + if (end_caret) + editor->move_caret_end(true); editor->textbase().reset(); API::update_window(this->handle()); @@ -358,7 +361,7 @@ namespace drawerbase { if(editor) { if(at_caret == false) - editor->move_caret_end(); + editor->move_caret_end(false); editor->put(to_wstring(text)); API::update_window(this->handle());