fix issue that content_view doesn't scroll the content

This commit is contained in:
Jinhao
2017-04-30 12:10:20 +08:00
parent 855694e8c7
commit 32792794ed

View File

@@ -31,6 +31,7 @@ namespace nana {
nana::size extra_px; nana::size extra_px;
bool enable_update{ true }; bool enable_update{ true };
bool drag_started{ false };
point origin; point origin;
nana::scroll<false> horz; nana::scroll<false> horz;
@@ -96,7 +97,10 @@ namespace nana {
if (!arg.is_left_button()) if (!arg.is_left_button())
return; return;
if (this->drive(arg.pos, true)) if ((!this->drag_started) && this->view.view_area().is_hit(arg.pos))
this->drag_started = true;
if (this->drag_started && this->drive(arg.pos))
{ {
tmr.interval(16); tmr.interval(16);
tmr.start(); tmr.start();
@@ -104,6 +108,7 @@ namespace nana {
} }
else if (event_code::mouse_up == arg.evt_code) else if (event_code::mouse_up == arg.evt_code)
{ {
this->drag_started = false;
tmr.stop(); tmr.stop();
} }
}; };
@@ -116,7 +121,7 @@ namespace nana {
auto curs = ::nana::API::cursor_position(); auto curs = ::nana::API::cursor_position();
::nana::API::calc_window_point(window_handle, curs); ::nana::API::calc_window_point(window_handle, curs);
if (this->drive(curs, false)) if (this->drive(curs))
{ {
if (events.hover_outside) if (events.hover_outside)
events.hover_outside(curs); events.hover_outside(curs);
@@ -129,13 +134,10 @@ namespace nana {
}); });
} }
bool drive(const point& cursor_pos, bool check_cursor_pos) bool drive(const point& cursor_pos)
{ {
auto const area = view.view_area(); auto const area = view.view_area();
if (check_cursor_pos && !area.is_hit(cursor_pos))
return false;
point skew; point skew;
if (disp_area.x > cursor_pos.x) if (disp_area.x > cursor_pos.x)