fix textbox caret_pos issue

This commit is contained in:
Jinhao 2016-08-27 05:23:25 +08:00
parent 1fd0da7d79
commit b13f0a4ce5
3 changed files with 10 additions and 3 deletions

View File

@ -215,7 +215,11 @@ namespace nana{ namespace widgets
std::wstring text() const; std::wstring text() const;
/// Sets caret position through text coordinate. /// Sets caret position through text coordinate.
void move_caret(const upoint&); /**
* @param pos the text position
* @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.
*/
void move_caret(const upoint& pos, bool reset = false);
void move_caret_end(); void move_caret_end();
void reset_caret_pixels() const; void reset_caret_pixels() const;
void reset_caret(); void reset_caret();

View File

@ -1840,8 +1840,11 @@ namespace nana{ namespace widgets
//move_caret //move_caret
//Set caret position through text coordinate //Set caret position through text coordinate
void text_editor::move_caret(const upoint& crtpos) void text_editor::move_caret(const upoint& crtpos, bool reset_caret)
{ {
if (reset_caret)
points_.caret = crtpos;
if (!API::is_focus_ready(window_)) if (!API::is_focus_ready(window_))
return; return;

View File

@ -345,7 +345,7 @@ namespace drawerbase {
auto editor = get_drawer_trigger().editor(); auto editor = get_drawer_trigger().editor();
internal_scope_guard lock; internal_scope_guard lock;
if (editor) if (editor)
editor->move_caret(pos); editor->move_caret(pos, true);
return *this; return *this;
} }