input: don't invoke keybinding when handler was just closed

This commit is contained in:
Moritz Zwerger 2023-10-31 22:08:48 +01:00
parent 351267d8cb
commit d27b977ab3
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 4 additions and 5 deletions

View File

@ -77,6 +77,7 @@ class InputManager(
} }
private fun onKey(code: KeyCodes, change: KeyChangeTypes) { private fun onKey(code: KeyCodes, change: KeyChangeTypes) {
val handler = this.handler.handler
this.handler.onKey(code, change) this.handler.onKey(code, change)
val pressed = when (change) { val pressed = when (change) {
@ -94,8 +95,7 @@ class InputManager(
this.pressed -= code this.pressed -= code
} }
val handler = this.handler.handler bindings.onKey(code, pressed, handler, millis)
bindings.onKey(code, pressed, millis)
if (pressed) { if (pressed) {
times[code] = millis times[code] = millis

View File

@ -20,6 +20,7 @@ import de.bixilon.minosoft.config.key.KeyActions
import de.bixilon.minosoft.config.key.KeyBinding import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.data.registries.identified.ResourceLocation import de.bixilon.minosoft.data.registries.identified.ResourceLocation
import de.bixilon.minosoft.gui.rendering.input.InputHandler
import de.bixilon.minosoft.gui.rendering.input.key.manager.InputManager import de.bixilon.minosoft.gui.rendering.input.key.manager.InputManager
import de.bixilon.minosoft.gui.rendering.input.key.manager.binding.actions.KeyActionFilter.Companion.filter import de.bixilon.minosoft.gui.rendering.input.key.manager.binding.actions.KeyActionFilter.Companion.filter
@ -100,9 +101,7 @@ class BindingsManager(
} }
} }
fun onKey(code: KeyCodes, pressed: Boolean, millis: Long) { fun onKey(code: KeyCodes, pressed: Boolean, handler: InputHandler?, millis: Long) {
val handler = input.handler.handler
for ((name, state) in bindings) { for ((name, state) in bindings) {
if (handler != null && !state.binding.ignoreConsumer) { if (handler != null && !state.binding.ignoreConsumer) {
continue continue