fabmax / kool

An OpenGL / WebGPU engine for Desktop JVM, Android and Javascript written in Kotlin
https://fabmax.github.io/kool/kool-js
Apache License 2.0
273 stars 16 forks source link

Keyboard input #50

Closed donaldr closed 1 year ago

donaldr commented 1 year ago

From what I see in kool/input/PlatformInput.kt it appears that kool captures all keypresses in the document. I'm planning on using kool in a non fullscreen canvas that has other components on the page. It would be better to only capture keyboard when the canvas is in focus (using tabindex) or perhaps provide an option to do so.

fabmax commented 1 year ago

Good point, I added an option to allow that. Now, per-canvas key-events can be enabled like this (global document keye event capture remains the default):

fun main() = KoolApplication(
    KoolConfig(isGlobalKeyEventGrabbing = false)
) {
    // application code...
}
donaldr commented 1 year ago

Amazing! Is this change published to the Maven repository? Really looking forward to diving deeper in to this library!

On Thu, May 25, 2023, 6:34 PM Max Thiele @.***> wrote:

Good point, I added https://github.com/fabmax/kool/commit/69f2d90374a13144c04cd0014ba4a9b7bd986360 an option to allow that. Now, per-canvas key-events can be enabled like this (global document keye event capture remains the default):

fun main() = KoolApplication( KoolConfig(isGlobalKeyEventGrabbing = false) ) { // application code... }

— Reply to this email directly, view it on GitHub https://github.com/fabmax/kool/issues/50#issuecomment-1563592296, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACQBFCUJPNDO4A36PSMGKDXH7NAHANCNFSM6AAAAAAYPIWZEQ . You are receiving this because you authored the thread.Message ID: @.***>

fabmax commented 1 year ago

It's included in the latest snapshot:

repositories {
    maven("https://oss.sonatype.org/content/repositories/snapshots")
}

dependencies {
    implementation("de.fabmax.kool:kool-core:0.12.0-SNAPSHOT")
    implementation("de.fabmax.kool:kool-physics:0.12.0-SNAPSHOT")
}