From 427f490f44f2da6c98f2ac8f2641920cb15cd577 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 21 Jun 2021 21:56:08 -0400 Subject: [PATCH] Handle middle-click in ScrollWidget before children can consume it. --- src/ui/ScrollWidget.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/ui/ScrollWidget.cpp b/src/ui/ScrollWidget.cpp index 9ca86d38..26709bae 100644 --- a/src/ui/ScrollWidget.cpp +++ b/src/ui/ScrollWidget.cpp @@ -90,25 +90,21 @@ void ScrollWidget::step() { void ScrollWidget::onButton(const ButtonEvent& e) { math::Rect offsetBound = getContainerOffsetBound(); - // Handle Alt-click before children, since most widgets consume Alt-click without needing to. - if (e.button == GLFW_MOUSE_BUTTON_LEFT && e.mods == GLFW_MOD_ALT) { - // Check if scrollable - if (offsetBound.size.x > 0.f || offsetBound.size.y > 0.f) { + // Check if scrollable + if (offsetBound.size.x > 0.f || offsetBound.size.y > 0.f) { + // Handle Alt-click before children, since most widgets consume Alt-click without needing to. + if (e.button == GLFW_MOUSE_BUTTON_LEFT && e.mods == GLFW_MOD_ALT) { e.consume(this); return; } - } - - Widget::onButton(e); - if (e.isConsumed()) - return; - - // Check if scrollable - if (offsetBound.size.x > 0.f || offsetBound.size.y > 0.f) { + // Might as well handle middle click before children as well. if (e.button == GLFW_MOUSE_BUTTON_MIDDLE) { e.consume(this); + return; } } + + Widget::onButton(e); }