diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt index 4ab602abd..277289b7c 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/client/AndroidMenuKeyMapping.kt @@ -45,6 +45,20 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon private var clickOnce = false + private fun resetState() { + selectedFeature = null + lastSelectedFeature = null + lastSelectedDegree = null + lastSelectProgress.clear() + clickOnce = false + holdIt = null + } + + private fun ohNoIHaveHitSomethingNastyInMinecraftCode() { + grabbedInput = false + resetState() + } + override fun setDown(isDown: Boolean) { val old = this.isDown super.setDown(isDown) @@ -77,17 +91,24 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon } } - selectedFeature = null - lastSelectedFeature = null - lastSelectedDegree = null - lastSelectProgress.clear() - clickOnce = false - holdIt = null + resetState() } } fun onMouseClick(event: InputEvent.MouseButton.Pre) { + // fix binding wheel menu to mouse button not calling back setIsDown(false) + if (isDown && event.action == 0 && key.type == InputConstants.Type.MOUSE && InputConstants.Type.MOUSE.getOrCreate(event.button) == key) { + isDown = false + return + } + if (grabbedInput) { + if (minecraft.screen != null) { + // whoopsie + ohNoIHaveHitSomethingNastyInMinecraftCode() + return + } + clickOnce = true event.isCanceled = true @@ -298,7 +319,7 @@ object AndroidMenuKeyMapping : KeyMapping("key.otm.android_menu", KeyConflictCon renderWheel(event) if (minecraft.screen != null) { - isDown = false + ohNoIHaveHitSomethingNastyInMinecraftCode() } } }