Added select_points method

This commit is contained in:
Eduardo Roeder 2018-11-03 14:58:53 -03:00
parent d2743bb817
commit 7651b430eb
3 changed files with 23 additions and 3 deletions

View File

@ -167,6 +167,8 @@ namespace nana{ namespace widgets
bool select(bool);
bool select_points(nana::upoint arg_a, nana::upoint arg_b);
/// Sets the end position of a selected string.
void set_end_caret(bool stay_in_view);

View File

@ -1845,11 +1845,11 @@ namespace nana{ namespace widgets
bool text_editor::select(bool yes)
{
if(yes)
if (yes)
{
select_.a.x = select_.a.y = 0;
select_.b.y = static_cast<unsigned>(impl_->textbase.lines());
if(select_.b.y) --select_.b.y;
if (select_.b.y) --select_.b.y;
select_.b.x = static_cast<unsigned>(impl_->textbase.getline(select_.b.y).size());
select_.mode_selection = selection::mode::method_selected;
impl_->try_refresh = sync_graph::refresh;
@ -1865,6 +1865,15 @@ namespace nana{ namespace widgets
return false;
}
bool text_editor::select_points(nana::upoint arg_a, nana::upoint arg_b)
{
select_.a = arg_a;
select_.b = arg_b;
select_.mode_selection = selection::mode::method_selected;
impl_->try_refresh = sync_graph::refresh;
return true;
}
void text_editor::set_end_caret(bool stay_in_view)
{
bool new_sel_end = (select_.b != points_.caret);

View File

@ -584,7 +584,16 @@ namespace drawerbase {
{
internal_scope_guard lock;
auto editor = get_drawer_trigger().editor();
if(editor && editor->select(yes))
if (editor && editor->select(yes))
API::refresh_window(*this);
}
void textbox::select_points(nana::upoint arg_a, nana::upoint arg_b)
{
auto editor = get_drawer_trigger().editor();
internal_scope_guard lock;
if (editor && editor->select_points(arg_a, arg_b))
API::refresh_window(*this);
}