diff options
Diffstat (limited to 'src/ui/controls/scroll_control.cpp')
-rw-r--r-- | src/ui/controls/scroll_control.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/ui/controls/scroll_control.cpp b/src/ui/controls/scroll_control.cpp index 07715892..9681924d 100644 --- a/src/ui/controls/scroll_control.cpp +++ b/src/ui/controls/scroll_control.cpp @@ -62,7 +62,7 @@ namespace cru::ui::controls } }); - mouse_down_event.bubble.AddHandler([this](events::MouseButtonEventArgs& args) + mouse_down_event.tunnel.AddHandler([this](events::MouseButtonEventArgs& args) { if (args.GetMouseButton() == MouseButton::Left) { @@ -72,6 +72,7 @@ namespace cru::ui::controls GetWindow()->CaptureMouseFor(this); is_pressing_scroll_bar_ = Orientation::Vertical; pressing_delta_ = point.y - vertical_bar_info_.bar.top; + args.SetHandled(); return; } @@ -80,12 +81,13 @@ namespace cru::ui::controls GetWindow()->CaptureMouseFor(this); pressing_delta_ = point.x - horizontal_bar_info_.bar.left; is_pressing_scroll_bar_ = Orientation::Horizontal; + args.SetHandled(); return; } } }); - mouse_move_event.bubble.AddHandler([this](events::MouseEventArgs& args) + mouse_move_event.tunnel.AddHandler([this](events::MouseEventArgs& args) { const auto mouse_point = args.GetPoint(this); @@ -94,6 +96,7 @@ namespace cru::ui::controls const auto new_head_position = mouse_point.x - pressing_delta_; const auto new_offset = new_head_position / horizontal_bar_info_.border.width * view_width_; SetScrollOffset(new_offset, std::nullopt); + args.SetHandled(); return; } @@ -102,16 +105,18 @@ namespace cru::ui::controls const auto new_head_position = mouse_point.y - pressing_delta_; const auto new_offset = new_head_position / vertical_bar_info_.border.height * view_height_; SetScrollOffset(std::nullopt, new_offset); + args.SetHandled(); return; } }); - mouse_up_event.bubble.AddHandler([this](events::MouseButtonEventArgs& args) + mouse_up_event.tunnel.AddHandler([this](events::MouseButtonEventArgs& args) { if (args.GetMouseButton() == MouseButton::Left && is_pressing_scroll_bar_.has_value()) { GetWindow()->ReleaseCurrentMouseCapture(); is_pressing_scroll_bar_ = std::nullopt; + args.SetHandled(); } }); @@ -126,12 +131,14 @@ namespace cru::ui::controls if (IsVerticalScrollEnabled() && GetScrollOffsetY() != (args.GetDelta() > 0.0f ? 0.0f : AtLeast0(GetViewHeight() - content_rect.height))) { SetScrollOffset(std::nullopt, GetScrollOffsetY() - args.GetDelta() / WHEEL_DELTA * view_delta); + args.SetHandled(); return; } if (IsHorizontalScrollEnabled() && GetScrollOffsetX() != (args.GetDelta() > 0.0f ? 0.0f : AtLeast0(GetViewWidth() - content_rect.width))) { SetScrollOffset(GetScrollOffsetX() - args.GetDelta() / WHEEL_DELTA * view_delta, std::nullopt); + args.SetHandled(); return; } }); |