From 464e1aa57993cd1dbe2b097ee1613e853146412e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 20 Aug 2023 20:35:20 +0700 Subject: [PATCH] Fix root frame children outside frame bounds not receiving isHovered flag --- .../mc/otm/client/screen/panels/EditablePanel.kt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt index d8360abcd..b18ff638d 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/panels/EditablePanel.kt @@ -925,10 +925,20 @@ open class EditablePanel @JvmOverloads constructor( if (isRemoved) return false - if (parent == null) - updateAbsolutePosition() + val potentiallyHovered: Boolean - if (mouseX in absoluteX ..< absoluteX + childrenRectWidth.coerceAtLeast(width) && mouseY in absoluteY ..< absoluteY + childrenRectHeight.coerceAtLeast(height)) { + if (parent == null) { + updateAbsolutePosition() + potentiallyHovered = + mouseX in absoluteX + childrenRectX.coerceAtMost(0f) ..< absoluteX + childrenRectWidth.coerceAtLeast(width) && + mouseY in absoluteY + childrenRectY.coerceAtMost(0f) ..< absoluteY + childrenRectHeight.coerceAtLeast(height) + } else { + potentiallyHovered = + mouseX in absoluteX ..< absoluteX + width && + mouseY in absoluteY ..< absoluteY + height + } + + if (potentiallyHovered) { var hit = false for (child in visibleChildrenInternal) {