1

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.

jeremie_se
  • 380
  • 1
  • 2
  • 14
  • I've seen these links of course: - https://stackoverflow.com/questions/53852043/problems-with-touch-input-and-openjdk-11-with-javafx-11 - https://github.com/javafxports/openjdk-jfx/issues/329 - https://bugs.openjdk.java.net/browse/JDK-8217955 But the issue does not seem to be fixed. Is anyone using JavaFX for touch that works beyond Java 8? – jeremie_se Mar 17 '21 at 14:06
  • The only way I've found is to trick the app by having my event listeners on MOUSE_EXITED_TARGET to simulate a touch release, but then I have to disable/ignore/etc. the mouse events; otherwise, just hovering on a button with the mouse triggers a click. – jeremie_se Mar 17 '21 at 14:28

1 Answers1

2

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)
}
jeremie_se
  • 380
  • 1
  • 2
  • 14