fix issue when textbox::reset with no parameter
This commit is contained in:
parent
8b652ee308
commit
4b58704161
@ -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.
|
* @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);
|
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_pixels() const;
|
||||||
void reset_caret();
|
void reset_caret();
|
||||||
void show_caret(bool isshow);
|
void show_caret(bool isshow);
|
||||||
|
|||||||
@ -1797,7 +1797,7 @@ namespace nana{ namespace widgets
|
|||||||
if (select_all)
|
if (select_all)
|
||||||
{
|
{
|
||||||
select(true);
|
select(true);
|
||||||
move_caret_end();
|
move_caret_end(false);
|
||||||
renderred = true;
|
renderred = true;
|
||||||
|
|
||||||
//If the text widget is focused by clicking mouse button, the selected text will be cancelled
|
//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;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
//move_caret
|
|
||||||
//Set caret position through text coordinate
|
|
||||||
bool text_editor::move_caret(const upoint& crtpos, bool reset_caret)
|
bool text_editor::move_caret(const upoint& crtpos, bool reset_caret)
|
||||||
{
|
{
|
||||||
const unsigned line_pixels = line_height();
|
const unsigned line_pixels = line_height();
|
||||||
@ -2036,11 +2034,14 @@ namespace nana{ namespace widgets
|
|||||||
return false;
|
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());
|
points_.caret.y = static_cast<unsigned>(impl_->textbase.lines());
|
||||||
if(points_.caret.y) --points_.caret.y;
|
if(points_.caret.y) --points_.caret.y;
|
||||||
points_.caret.x = static_cast<unsigned>(impl_->textbase.getline(points_.caret.y).size());
|
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
|
void text_editor::reset_caret_pixels() const
|
||||||
|
|||||||
@ -260,8 +260,11 @@ namespace drawerbase {
|
|||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
auto editor = get_drawer_trigger().editor();
|
auto editor = get_drawer_trigger().editor();
|
||||||
if (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();
|
editor->textbase().reset();
|
||||||
API::update_window(this->handle());
|
API::update_window(this->handle());
|
||||||
@ -358,7 +361,7 @@ namespace drawerbase {
|
|||||||
if(editor)
|
if(editor)
|
||||||
{
|
{
|
||||||
if(at_caret == false)
|
if(at_caret == false)
|
||||||
editor->move_caret_end();
|
editor->move_caret_end(false);
|
||||||
|
|
||||||
editor->put(to_wstring(text));
|
editor->put(to_wstring(text));
|
||||||
API::update_window(this->handle());
|
API::update_window(this->handle());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user