aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuuz <6596629+Juuxel@users.noreply.github.com>2022-09-06 14:26:16 +0300
committerJuuz <6596629+Juuxel@users.noreply.github.com>2022-09-06 14:26:16 +0300
commit76344e9eb57b77c3ef2a6405e8c9752c959d2d0e (patch)
tree60e51ca575254c54ffcf4991813857f51ec436be
parent82950d5b4a58699ae816b5279c27d344d9e98185 (diff)
downloadLibGui-76344e9eb57b77c3ef2a6405e8c9752c959d2d0e.tar.gz
LibGui-76344e9eb57b77c3ef2a6405e8c9752c959d2d0e.tar.bz2
LibGui-76344e9eb57b77c3ef2a6405e8c9752c959d2d0e.zip
Use WWidget.isWithinBounds in WPanel.hit
-rw-r--r--src/main/java/io/github/cottonmc/cotton/gui/widget/WPanel.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/main/java/io/github/cottonmc/cotton/gui/widget/WPanel.java b/src/main/java/io/github/cottonmc/cotton/gui/widget/WPanel.java
index b6d0169..a853b24 100644
--- a/src/main/java/io/github/cottonmc/cotton/gui/widget/WPanel.java
+++ b/src/main/java/io/github/cottonmc/cotton/gui/widget/WPanel.java
@@ -104,11 +104,10 @@ public abstract class WPanel extends WWidget {
if (children.isEmpty()) return this;
for(int i=children.size()-1; i>=0; i--) { //Backwards so topmost widgets get priority
WWidget child = children.get(i);
- if ( x>=child.getX() &&
- y>=child.getY() &&
- x<child.getX()+child.getWidth() &&
- y<child.getY()+child.getHeight()) {
- return child.hit(x-child.getX(), y-child.getY());
+ int wx = x - child.getX();
+ int wy = y - child.getY();
+ if (child.isWithinBounds(wx, wy)) {
+ return child.hit(wx, wy);
}
}
return this;