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 976303274..8679606a7 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 @@ -318,10 +318,11 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit override fun mouseClicked(x: Double, y: Double, button: Int): Boolean { var click = false + var focusKilled = false for (panel in panels) { if (click || !panel.mouseClickedChecked(x, y, button)) { - panel.killFocusForEverythingExceptInner() + focusKilled = panel.killFocusForEverythingExceptInner() || focusKilled } else { if (returnSlot != null) { super.mouseClicked(x, y, button) @@ -332,7 +333,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - return true + return click || focusKilled } private var lastDragSlot: Slot? = null @@ -350,7 +351,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - return true + return false } override fun mouseReleased(p_97812_: Double, p_97813_: Double, p_97814_: Int): Boolean { @@ -388,7 +389,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - return true + return false } override fun keyReleased(p_94715_: Int, p_94716_: Int, p_94717_: Int): Boolean { @@ -398,7 +399,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - return true + return false } override fun charTyped(p_94683_: Char, p_94684_: Int): Boolean { @@ -408,7 +409,7 @@ abstract class MatteryScreen(menu: T, inventory: Inventory, tit } } - return true + return false } override fun keyPressed(key: Int, scancode: Int, mods: Int): Boolean { 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 1aecb526d..864394e24 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 @@ -1108,16 +1108,24 @@ open class EditablePanel @JvmOverloads constructor( } } - private fun killFocusInternal() { + private fun killFocusInternal(): Boolean { + var status = false + for (child in childrenInternal) { - child.killFocusInternal() + status = child.killFocusInternal() || status } if (isFocused) { isFocused = false + status = true } - grabMouseInput = false + if (grabMouseInput) { + grabMouseInput = false + status = true + } + + return status } private fun killGrabMouseInput() { @@ -1128,13 +1136,17 @@ open class EditablePanel @JvmOverloads constructor( grabMouseInput = false } - fun killFocus() { + fun killFocus(): Boolean { if (isEverFocused()) { - killFocusInternal() + val status = killFocusInternal() findAbsoluteRoot().updateFocus() + return status } else if (isGrabbingMouseInput()) { killGrabMouseInput() + return true } + + return false } fun findHierarchicalFocus(): EditablePanel<*>? { @@ -1310,14 +1322,18 @@ open class EditablePanel @JvmOverloads constructor( } } - fun killFocusForEverythingExceptInner() { + fun killFocusForEverythingExceptInner(): Boolean { + var focusKilled = false + for (child in childrenInternal) { - child.killFocusForEverythingExceptInner() + focusKilled = child.killFocusForEverythingExceptInner() || focusKilled } if (autoKillFocus) { - killFocus() + focusKilled = killFocus() || focusKilled } + + return focusKilled } final override fun mouseClicked(x: Double, y: Double, button: Int): Boolean {