From c69781c22c0d091a2d247f235ad948b215babae8 Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Thu, 4 Jan 2024 19:08:20 +0700 Subject: [PATCH] Fix cursor wars between panels when grabbing mouse input --- .../mc/otm/client/screen/MatteryScreen.kt | 3 +++ .../mc/otm/client/screen/panels/EditablePanel.kt | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt index 1121a8146..d202792dd 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/screen/MatteryScreen.kt @@ -672,6 +672,9 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit panel.render(wrap, mouseXf, mouseYf, partialTick) } + if (!panels.asReversed().any { it.updateCursor0() }) + panels.asReversed().any { it.updateCursor1() } + RenderSystem.depthFunc(GL11.GL_LESS) MinecraftForge.EVENT_BUS.post(Background(this, graphics, mouseX, mouseY)) RenderSystem.disableDepthTest() 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 8cea8bc95..f0064faec 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 @@ -900,10 +900,24 @@ open class EditablePanel @JvmOverloads constructor( if (scissor) { popScissorRect() } + } - if (isHovered || grabMouseInput) { + fun updateCursor0(): Boolean { + if (grabMouseInput) { cursorType.setTo() + return true } + + return children.any { it.updateCursor0() } + } + + fun updateCursor1(): Boolean { + if (isHovered) { + cursorType.setTo() + return true + } + + return children.any { it.updateCursor1() } } fun updateAbsolutePosition() {