diff --git a/include/nana/gui/widgets/skeletons/text_editor.hpp b/include/nana/gui/widgets/skeletons/text_editor.hpp index dd24d365..12b23ced 100644 --- a/include/nana/gui/widgets/skeletons/text_editor.hpp +++ b/include/nana/gui/widgets/skeletons/text_editor.hpp @@ -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); diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index ca070ace..d7a9fd4a 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -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(impl_->textbase.lines()); - if(select_.b.y) --select_.b.y; + if (select_.b.y) --select_.b.y; select_.b.x = static_cast(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); diff --git a/source/gui/widgets/textbox.cpp b/source/gui/widgets/textbox.cpp index 96c88d6c..8695f1e5 100644 --- a/source/gui/widgets/textbox.cpp +++ b/source/gui/widgets/textbox.cpp @@ -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); }