Fix isHovered being false when outside of parent's bounds
This commit is contained in:
parent
9f6b884c8c
commit
bc6bb15874
@ -381,6 +381,9 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
if (parent == null) {
|
||||
absoluteX = x
|
||||
absoluteY = y
|
||||
} else {
|
||||
if (x < 0f || y < 0f || x + width > parent.width || y + height > parent.height) {
|
||||
// no op - we updated ourselves in tickHover
|
||||
} else {
|
||||
isHovered = parent.isHovered &&
|
||||
mouseX >= absoluteX &&
|
||||
@ -388,6 +391,7 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
mouseY >= absoluteY &&
|
||||
mouseY < absoluteY + height
|
||||
}
|
||||
}
|
||||
|
||||
val scissor = this.scissor
|
||||
|
||||
@ -426,6 +430,23 @@ open class EditablePanel @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
open fun tickHover(mouse_x: Float, mouse_y: Float): Boolean {
|
||||
if (boundingHeight > height || boundingWidth > width || boundingX < 0 || boundingY < 0) {
|
||||
var hit = false
|
||||
|
||||
for (child in children) {
|
||||
if (child.tickHover(mouse_x, mouse_y)) {
|
||||
hit = true
|
||||
}
|
||||
}
|
||||
|
||||
isHovered = mouse_x >= absoluteX &&
|
||||
mouse_x <= absoluteX + width &&
|
||||
mouse_y >= absoluteY &&
|
||||
mouse_y <= absoluteY + height
|
||||
|
||||
return hit
|
||||
}
|
||||
|
||||
isHovered =
|
||||
mouse_x >= absoluteX &&
|
||||
mouse_x <= absoluteX + width &&
|
||||
|
Loading…
Reference in New Issue
Block a user