KeyPressDispatcher no longer silently eats exceptions (#6931)

This commit is contained in:
SomeTroglodyte 2022-05-25 18:32:24 +02:00 committed by GitHub
parent fe0ec08e61
commit 6f7af9ee22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,7 +15,7 @@ import com.badlogic.gdx.scenes.scene2d.Stage
* (Exception: international keyboard AltGr-combos) * (Exception: international keyboard AltGr-combos)
* An update supporting easy declarations for any modifier combos would need to use Gdx.input.isKeyPressed() * An update supporting easy declarations for any modifier combos would need to use Gdx.input.isKeyPressed()
* Gdx seems to omit support for a modifier mask (e.g. Ctrl-Alt-Shift) so we would need to reinvent this * Gdx seems to omit support for a modifier mask (e.g. Ctrl-Alt-Shift) so we would need to reinvent this
* *
* Note: It is important that KeyCharAndCode is an immutable data class to support usage as HashMap key * Note: It is important that KeyCharAndCode is an immutable data class to support usage as HashMap key
*/ */
@ -203,12 +203,9 @@ class KeyPressDispatcher(val name: String? = null) : HashMap<KeyCharAndCode, (()
return super.keyDown(event, keycode) return super.keyDown(event, keycode)
} }
// try-catch mainly for debugging. Breakpoints in the vicinity can make the event fire twice in rapid succession, second time the context can be invalid
if (consoleLog) if (consoleLog)
println("${this@KeyPressDispatcher}: handling $key") println("${this@KeyPressDispatcher}: handling $key")
try { this@KeyPressDispatcher[key]?.invoke()
this@KeyPressDispatcher[key]?.invoke()
} catch (ex: Exception) {}
return true return true
} }
} }