Do nnt allow mouse events outside of visible region

This commit is contained in:
Frank 2022-07-16 14:01:31 +02:00
parent bebd7e1c70
commit e33fa75716

View file

@ -175,7 +175,7 @@ public class VerticalScroll<R extends ComponentRenderer, RS extends ScrollerRend
@Override @Override
public void mouseMoved(double x, double y) { public void mouseMoved(double x, double y) {
if (child != null) if (child != null && relativeBounds.contains(x, y))
child.mouseMoved(x, y); child.mouseMoved(x, y);
} }
@ -190,7 +190,7 @@ public class VerticalScroll<R extends ComponentRenderer, RS extends ScrollerRend
return true; return true;
} }
if (child != null) if (child != null && relativeBounds.contains(x, y))
return child.mouseClicked(x, y, button); return child.mouseClicked(x, y, button);
return false; return false;
} }
@ -198,7 +198,7 @@ public class VerticalScroll<R extends ComponentRenderer, RS extends ScrollerRend
@Override @Override
public boolean mouseReleased(double x, double y, int button) { public boolean mouseReleased(double x, double y, int button) {
mouseDown = false; mouseDown = false;
if (child != null) if (child != null && relativeBounds.contains(x, y))
return child.mouseReleased(x - relativeBounds.left, y - relativeBounds.top, button); return child.mouseReleased(x - relativeBounds.left, y - relativeBounds.top, button);
return false; return false;
} }
@ -210,14 +210,14 @@ public class VerticalScroll<R extends ComponentRenderer, RS extends ScrollerRend
scrollerY = scrollerDownY + delta; scrollerY = scrollerDownY + delta;
return true; return true;
} }
if (child != null) if (child != null && relativeBounds.contains(x, y))
return child.mouseDragged(x, y, button, x2, y2); return child.mouseDragged(x, y, button, x2, y2);
return false; return false;
} }
@Override @Override
public boolean mouseScrolled(double x, double y, double f) { public boolean mouseScrolled(double x, double y, double f) {
if (child != null) if (child != null && relativeBounds.contains(x, y))
return child.mouseScrolled(x, y, f); return child.mouseScrolled(x, y, f);
return false; return false;
} }