From 32792794ede7bbd20ce82bfec70fb2e25639ea92 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 30 Apr 2017 12:10:20 +0800 Subject: [PATCH] fix issue that content_view doesn't scroll the content --- source/gui/widgets/skeletons/content_view.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/source/gui/widgets/skeletons/content_view.cpp b/source/gui/widgets/skeletons/content_view.cpp index b9edd77d..4dfc49a0 100644 --- a/source/gui/widgets/skeletons/content_view.cpp +++ b/source/gui/widgets/skeletons/content_view.cpp @@ -31,6 +31,7 @@ namespace nana { nana::size extra_px; bool enable_update{ true }; + bool drag_started{ false }; point origin; nana::scroll horz; @@ -96,7 +97,10 @@ namespace nana { if (!arg.is_left_button()) 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.start(); @@ -104,6 +108,7 @@ namespace nana { } else if (event_code::mouse_up == arg.evt_code) { + this->drag_started = false; tmr.stop(); } }; @@ -116,7 +121,7 @@ namespace nana { auto curs = ::nana::API::cursor_position(); ::nana::API::calc_window_point(window_handle, curs); - if (this->drive(curs, false)) + if (this->drive(curs)) { if (events.hover_outside) 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(); - if (check_cursor_pos && !area.is_hit(cursor_pos)) - return false; - point skew; if (disp_area.x > cursor_pos.x)