jeremie_se
jeremie_se

Reputation: 380

JavaFX Touch Events Not Triggering - Ubuntu 20.04 touch laptop

I am developing a JavaFX application w/ OpenJDK 11 and OpenJFX 16.

App works great on Ubuntu 20.04 desktop w/ mouse, but on my Ubuntu 20.04 touch laptop, nothing works with the touch. The interface detects touch, but the events are all MOUSE_ENTERED_TARGET and MOUSE_EXITED_TARGET. It won't detect the actual touch like it does the click. I've read that others had issues w/ that w/ OpenJFX 11, but I thought that JavaFX supports touch since JavaFX 2.2.

Is there anything I must manually do for a normal JavaFX button to recognize a touch event.

Upvotes: 1

Views: 768

Answers (1)

jeremie_se
jeremie_se

Reputation: 380

SOLVED The solution was to properly add '-Djdk.gtk.version=2' for touch to work. Then it worked w/o me having to do anything specific in event handlers. The issue was also compounded by the fact that in my build.gradle.kts file under application I had to set applicationDefaultJvmArgs = listOf("-Djdk.gtk.version=2") and also pass along the args: Array<String> to my main function/method:

@JvmStatic
fun main(args: Array<String>) {
    launch(MainLauncher::class.java, *args)
}

Upvotes: 2

Related Questions