fix issue when textbox::reset with no parameter

This commit is contained in:
Jinhao 2016-10-01 10:07:13 +08:00
parent 8b652ee308
commit 4b58704161
3 changed files with 12 additions and 8 deletions

View File

@ -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);

View File

@ -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<unsigned>(impl_->textbase.lines());
if(points_.caret.y) --points_.caret.y;
points_.caret.x = static_cast<unsigned>(impl_->textbase.getline(points_.caret.y).size());
if (update)
this->move_caret(points_.caret, false);
}
void text_editor::reset_caret_pixels() const

View File

@ -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());