Browse Source

Handle middle-click in ScrollWidget before children can consume it.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
427f490f44
1 changed files with 8 additions and 12 deletions
  1. +8
    -12
      src/ui/ScrollWidget.cpp

+ 8
- 12
src/ui/ScrollWidget.cpp View File

@@ -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);
}




Loading…
Cancel
Save