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(bool);
bool select_points(nana::upoint arg_a, nana::upoint arg_b);
/// Sets the end position of a selected string. /// Sets the end position of a selected string.
void set_end_caret(bool stay_in_view); void set_end_caret(bool stay_in_view);

View File

@ -1865,6 +1865,15 @@ namespace nana{ namespace widgets
return false; 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) void text_editor::set_end_caret(bool stay_in_view)
{ {
bool new_sel_end = (select_.b != points_.caret); bool new_sel_end = (select_.b != points_.caret);

View File

@ -588,6 +588,15 @@ namespace drawerbase {
API::refresh_window(*this); 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);
}
std::pair<upoint, upoint> textbox::selection() const std::pair<upoint, upoint> textbox::selection() const
{ {
std::pair<upoint, upoint> points; std::pair<upoint, upoint> points;