Fix cursor wars between panels when grabbing mouse input

This commit is contained in:
DBotThePony 2024-01-04 19:08:20 +07:00
parent 70ec49e546
commit c69781c22c
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 18 additions and 1 deletions

View File

@ -672,6 +672,9 @@ abstract class MatteryScreen<T : MatteryMenu>(menu: T, inventory: Inventory, tit
panel.render(wrap, mouseXf, mouseYf, partialTick) panel.render(wrap, mouseXf, mouseYf, partialTick)
} }
if (!panels.asReversed().any { it.updateCursor0() })
panels.asReversed().any { it.updateCursor1() }
RenderSystem.depthFunc(GL11.GL_LESS) RenderSystem.depthFunc(GL11.GL_LESS)
MinecraftForge.EVENT_BUS.post(Background(this, graphics, mouseX, mouseY)) MinecraftForge.EVENT_BUS.post(Background(this, graphics, mouseX, mouseY))
RenderSystem.disableDepthTest() RenderSystem.disableDepthTest()

View File

@ -900,10 +900,24 @@ open class EditablePanel<out S : Screen> @JvmOverloads constructor(
if (scissor) { if (scissor) {
popScissorRect() popScissorRect()
} }
if (isHovered || grabMouseInput) {
cursorType.setTo()
} }
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() { fun updateAbsolutePosition() {