diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index 562446b5..9489c8f4 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -2954,6 +2954,7 @@ namespace nana{ namespace widgets if (if_mask && mask_char_) mask_str.reset(new nana::string(str.size(), mask_char_)); + bool focused = API::is_focus_ready(window_); // do this many times is not efficient... auto & linestr = (if_mask && mask_char_ ? *mask_str : str); @@ -2976,7 +2977,7 @@ namespace nana{ namespace widgets graph_.set_color(scheme_->selection.get_color()); //The text is not selected or the whole line text is selected - if ((!_m_get_sort_select_points(a, b)) || (select_.a.y != str_pos.y && select_.b.y != str_pos.y)) + if (!focused || (!_m_get_sort_select_points(a, b)) || (select_.a.y != str_pos.y && select_.b.y != str_pos.y)) { bool selected = (a.y < str_pos.y && str_pos.y < b.y); for (auto & ent : reordered) @@ -2986,7 +2987,7 @@ namespace nana{ namespace widgets if ((text_pos.x + static_cast(str_w) > text_area_.area.x) && (text_pos.x < xend)) { - if (selected) + if (selected && focused) { graph_.set_text_color(scheme_->selection_text.get_color()); graph_.rectangle({ text_pos, { str_w, line_h_pixels } }, true); diff --git a/source/gui/widgets/textbox.cpp b/source/gui/widgets/textbox.cpp index fd2d9c86..13c68a26 100644 --- a/source/gui/widgets/textbox.cpp +++ b/source/gui/widgets/textbox.cpp @@ -89,7 +89,10 @@ namespace drawerbase { void drawer::focus(graph_reference graph, const arg_focus& arg) { refresh(graph); - + if (arg.getting) { + editor_->select(true); + editor_->move_caret_end(); + } editor_->show_caret(arg.getting); editor_->reset_caret(); API::lazy_refresh();