improve textbox's selection handling refs #19, #1

This commit is contained in:
beru 2015-05-24 23:25:39 +09:00
parent 2776365fdf
commit 21dc2aa48c
2 changed files with 9 additions and 28 deletions

View File

@ -1619,8 +1619,6 @@ namespace nana{ namespace widgets
//Set caret pos by screen point and get the caret pos. //Set caret pos by screen point and get the caret pos.
auto pos = mouse_caret(scrpos); auto pos = mouse_caret(scrpos);
if(!hit_select_area(pos))
{
if(!select(false)) if(!select(false))
{ {
select_.a = points_.caret; //Set begin caret select_.a = points_.caret; //Set begin caret
@ -1628,12 +1626,6 @@ namespace nana{ namespace widgets
} }
select_.mode_selection = selection::mode_mouse_selected; select_.mode_selection = selection::mode_mouse_selected;
} }
else
{
select(false);
select_.mode_selection = selection::mode_no_selected;
}
}
text_area_.border_renderer(graph_, _m_bgcolor()); text_area_.border_renderer(graph_, _m_bgcolor());
return true; return true;
@ -2345,22 +2337,12 @@ namespace nana{ namespace widgets
case keyboard::os_arrow_up: case keyboard::os_arrow_up:
case keyboard::os_home: case keyboard::os_home:
case keyboard::os_pageup: case keyboard::os_pageup:
if (points_.caret == select_.b) { select_.b = caret;
select_.b = select_.a;
}else {
select_.b = std::max(select_.b, points_.caret);
}
select_.a = caret;
break; break;
case keyboard::os_arrow_right: case keyboard::os_arrow_right:
case keyboard::os_arrow_down: case keyboard::os_arrow_down:
case keyboard::os_end: case keyboard::os_end:
case keyboard::os_pagedown: case keyboard::os_pagedown:
if (select_.b == points_.caret) {
select_.a = std::min(select_.a, points_.caret);
}else {
select_.a = std::max(select_.b, points_.caret);
}
select_.b = caret; select_.b = caret;
break; break;
} }
@ -2368,9 +2350,6 @@ namespace nana{ namespace widgets
select_.b = caret; select_.b = caret;
select_.a = caret; select_.a = caret;
} }
if (select_.a > select_.b) {
std::swap(select_.a, select_.b);
}
points_.caret = caret; points_.caret = caret;
behavior_->adjust_caret_into_screen(); behavior_->adjust_caret_into_screen();
render(true); render(true);

View File

@ -92,11 +92,13 @@ namespace drawerbase {
void drawer::focus(graph_reference graph, const arg_focus& arg) void drawer::focus(graph_reference graph, const arg_focus& arg)
{ {
refresh(graph); refresh(graph);
if (arg.getting) { if (!editor_->attr().multi_lines && arg.getting)
{
static auto& brock = detail::bedrock::instance(); static auto& brock = detail::bedrock::instance();
auto native_window = reinterpret_cast<native_window_type>(arg.receiver); auto native_window = reinterpret_cast<native_window_type>(arg.receiver);
auto* root_runtime = brock.wd_manager.root_runtime(native_window); auto* root_runtime = brock.wd_manager.root_runtime(native_window);
if (root_runtime && root_runtime->condition.tabstop_focus_changed) { if (root_runtime && root_runtime->condition.tabstop_focus_changed)
{
editor_->select(true); editor_->select(true);
editor_->move_caret_end(); editor_->move_caret_end();
} }