JavaFX 11 for JME

I’ve also noticed this in jfx “scrollable” components. Using the mouse wheel does not scroll properly when used in jme with your lib. Otherwise works fine in a standalone jfx app.

Looks like two different apps to me :thinking:

Yes! The problem may reside in the class JmeFXInputListener, the one that converts jme event to javafx event.

Only the mouse events are pass down to javafx, using the sceneInterface.

https://github.com/jayfella/jme-jfx-11/blob/f6e21a64ad2f0008346055409571b972534211a8/src/main/java/com/jayfella/jme/jfx/injme/input/JmeFXInputListener.java#L443

This interface also offers a method called scrollEvent. Calling this method might solve the problem.

Ok, I’ll take a look tomorrow.

I’ve done some quick tests. I have it working. It needs more work but long story short, I can get it working. It’s late here (UK) so it will have to be tomorrow.

I’ve pushed an update to jcenter. Vertical scrolling using the mouse wheel is now supported. I do not have a horizontal-scrolling mouse, so unfortunately I can’t do that.

compile 'com.jayfella:jme-jfx-11:1.1.2'
2 Likes

Great project. I have tested the example code. The vertical scrolling works now fine, but the horizontal scrolling still doesn’t work. Here is the log output:

For not-JME:

ScrollEvent [source = Button@392222a3[styleClass=button]'My Button', target = Button@392222a3[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = -40.0, deltaY = 0.0, totalDeltaX = 0.0, totalDeltaY = 0.0, textDeltaXUnits = NONE, textDeltaX = -0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 155.0, y = 1095.0, z = 0.0, indirect, pickResult = PickResult [node = Button@392222a3[styleClass=button]'My Button', point = Point3D [x = 155.0, y = 1095.0, z = 0.0], distance = 1250.237020535574]
ScrollEvent [source = Button@392222a3[styleClass=button]'My Button', target = Button@392222a3[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = -40.0, deltaY = 0.0, totalDeltaX = 0.0, totalDeltaY = 0.0, textDeltaXUnits = NONE, textDeltaX = -0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 170.0, y = 1095.0, z = 0.0, indirect, pickResult = PickResult [node = Button@392222a3[styleClass=button]'My Button', point = Point3D [x = 170.0, y = 1095.0, z = 0.0], distance = 1250.237020535574]
ScrollEvent [source = Button@392222a3[styleClass=button]'My Button', target = Button@392222a3[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = -40.0, deltaY = 0.0, totalDeltaX = 0.0, totalDeltaY = 0.0, textDeltaXUnits = NONE, textDeltaX = -0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 185.0, y = 1095.0, z = 0.0, indirect, pickResult = PickResult [node = Button@392222a3[styleClass=button]'My Button', point = Point3D [x = 185.0, y = 1095.0, z = 0.0], distance = 1250.237020535574]
ScrollEvent [source = Button@392222a3[styleClass=button]'My Button', target = Button@392222a3[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = -40.0, deltaY = 0.0, totalDeltaX = 0.0, totalDeltaY = 0.0, textDeltaXUnits = NONE, textDeltaX = -0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 200.0, y = 1095.0, z = 0.0, indirect, pickResult = PickResult [node = Button@392222a3[styleClass=button]'My Button', point = Point3D [x = 200.0, y = 1095.0, z = 0.0], distance = 1250.237020535574]
ScrollEvent [source = Button@392222a3[styleClass=button]'My Button', target = Button@392222a3[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = -40.0, deltaY = 0.0, totalDeltaX = 0.0, totalDeltaY = 0.0, textDeltaXUnits = NONE, textDeltaX = -0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 215.0, y = 1095.0, z = 0.0, indirect, pickResult = PickResult [node = Button@392222a3[styleClass=button]'My Button', point = Point3D [x = 215.0, y = 1095.0, z = 0.0], distance = 1250.237020535574]
ScrollEvent [source = Button@392222a3[styleClass=button]'My Button', target = Button@392222a3[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = -40.0, deltaY = 0.0, totalDeltaX = 0.0, totalDeltaY = 0.0, textDeltaXUnits = NONE, textDeltaX = -0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 229.0, y = 1095.0, z = 0.0, indirect, pickResult = PickResult [node = Button@392222a3[styleClass=button]'My Button', point = Point3D [x = 229.0, y = 1095.0, z = 0.0], distance = 1250.237020535574]
ScrollEvent [source = Button@392222a3[styleClass=button]'My Button', target = Button@392222a3[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = -40.0, deltaY = 0.0, totalDeltaX = 0.0, totalDeltaY = 0.0, textDeltaXUnits = NONE, textDeltaX = -0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 244.0, y = 1095.0, z = 0.0, indirect, pickResult = PickResult [node = Button@392222a3[styleClass=button]'My Button', point = Point3D [x = 244.0, y = 1095.0, z = 0.0], distance = 1250.237020535574]
ScrollEvent [source = Button@392222a3[styleClass=button]'My Button', target = Button@392222a3[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = -40.0, deltaY = 0.0, totalDeltaX = 0.0, totalDeltaY = 0.0, textDeltaXUnits = NONE, textDeltaX = -0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 259.0, y = 1095.0, z = 0.0, indirect, pickResult = PickResult [node = Button@392222a3[styleClass=button]'My Button', point = Point3D [x = 259.0, y = 1095.0, z = 0.0], distance = 1250.237020535574]

For MJE:

ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 361.0, y = 1063.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 361.0, y = 1063.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 361.0, y = 1063.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 361.0, y = 1063.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_MOVED, consumed = true, x = 362.0, y = 1063.0, z = 0.0, button = NONE, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1063.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 362.0, y = 1063.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1063.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 362.0, y = 1063.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1063.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_MOVED, consumed = true, x = 362.0, y = 1064.0, z = 0.0, button = NONE, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 362.0, y = 1064.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 362.0, y = 1064.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_MOVED, consumed = true, x = 362.0, y = 1064.0, z = 0.0, button = NONE, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 362.0, y = 1064.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 362.0, y = 1064.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_MOVED, consumed = true, x = 362.0, y = 1064.0, z = 0.0, button = NONE, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 362.0, y = 1064.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 362.0, y = 1064.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_MOVED, consumed = true, x = 362.0, y = 1064.0, z = 0.0, button = NONE, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 362.0, y = 1064.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 362.0, y = 1064.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_MOVED, consumed = true, x = 362.0, y = 1064.0, z = 0.0, button = NONE, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 362.0, y = 1064.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 362.0, y = 1064.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 362.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_MOVED, consumed = true, x = 363.0, y = 1064.0, z = 0.0, button = NONE, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 363.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 363.0, y = 1064.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 363.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 363.0, y = 1064.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 363.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_MOVED, consumed = true, x = 364.0, y = 1064.0, z = 0.0, button = NONE, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 364.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 364.0, y = 1064.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 364.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 364.0, y = 1064.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 364.0, y = 1064.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_MOVED, consumed = true, x = 364.0, y = 1065.0, z = 0.0, button = NONE, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 364.0, y = 1065.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 364.0, y = 1065.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 364.0, y = 1065.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 364.0, y = 1065.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 364.0, y = 1065.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_MOVED, consumed = true, x = 364.0, y = 1066.0, z = 0.0, button = NONE, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 364.0, y = 1066.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 364.0, y = 1066.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 364.0, y = 1066.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 364.0, y = 1066.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 364.0, y = 1066.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_MOVED, consumed = true, x = 365.0, y = 1068.0, z = 0.0, button = NONE, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 365.0, y = 1068.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 365.0, y = 1068.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 365.0, y = 1068.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 365.0, y = 1068.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 365.0, y = 1068.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_MOVED, consumed = true, x = 366.0, y = 1071.0, z = 0.0, button = NONE, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 366.0, y = 1071.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 366.0, y = 1071.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 366.0, y = 1071.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 366.0, y = 1071.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 366.0, y = 1071.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_MOVED, consumed = true, x = 367.0, y = 1073.0, z = 0.0, button = NONE, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 367.0, y = 1073.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 367.0, y = 1073.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 367.0, y = 1073.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 367.0, y = 1073.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 367.0, y = 1073.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_MOVED, consumed = true, x = 369.0, y = 1076.0, z = 0.0, button = NONE, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 369.0, y = 1076.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 369.0, y = 1076.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 369.0, y = 1076.0, z = 0.0], distance = 1679.4228634059948]
ScrollEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = SCROLL, consumed = false, deltaX = 0.0, deltaY = 0.0, totalDeltaX = 50.0, totalDeltaY = -93600.0, textDeltaXUnits = NONE, textDeltaX = 0.0, textDeltaYUnits = NONE, textDeltaY = 0.0, touchCount = 0, x = 369.0, y = 1076.0, z = 0.0, indirect, pickResult = PickResult [node = Button@43a26377[styleClass=button]'My Button', point = Point3D [x = 369.0, y = 1076.0, z = 0.0], distance = 1679.4228634059948]
MouseEvent [source = Button@43a26377[styleClass=button]'My Button', target = Button@43a26377[styleClass=button]'My Button', eventType = MOUSE_EXITED, consumed = true, x = 371.0, y = 1080.0, z = 0.0, button = NONE, pickResult = PickResult [node = StackPane@3fb96d94[styleClass=track], point = Point3D [x = 356.0, y = 1.0, z = 0.0], distance = 1679.4228634059948]

I’ll see if I can emulate it somehow next week when I’m back in action. I’m a bit busy with work this week.

I’ve updated this library to 1.1.3 to fix an issue relating to the jfx thread stopping unexpectedly when no scene is visible.

Thank you @tlf30 for the PR.

2 Likes

First off, let me say… this is one of my favorite libraries ever for jME, and it’s a lifesaver.

I’m having an issue with the dialogs not centering correctly. Here’s the relevant code:

public void alert(String title, String message){
	Platform.runLater(() -> {
			
		AlertDialog alert = createUIElement(CoreUIElements.ALERT_DIALOG, AlertDialog.class);
		alert.setContent(title, message);
		
		alert.setDismissAction((event) -> {
			JavaFxUI.getInstance().removeDialog();
		});
		
		JavaFxUI.getInstance().showDialog(alert, true);
	});
}

AlertDialog is a custom JavaFX control I made - it’s just a pane with some convenience methods added for setting content/action listeners. It never touches layout. The createUIElement() call just uses a factory to create a new instance, and it also doesn’t do anything with layout - the factory for that dialog is just () -> new AlertDialog().

What I expect to happen is that the dialog will display dead center in my screen. What happens instead is the upper-left corner of the dialog is centered in my screen.

Is there something else I should be looking for here, or are there other folks also having issues with dialogs not centering?

I will preface by saying maybe I am misunderstanding the question and if so I apologize in advance.

I thought this was expected behavior? Thats how other libraries work.

Can you get the dialogs size and make adjustments?

This is how Paul does it in Lemur.

    public void centerCont(Container cont) {
        // Position the panel.  
        Vector3f pref = cont.getPreferredSize().clone();
        float scale = 0.5f;
        float width = getApplication().getCamera().getWidth() * scale;
        float height = getApplication().getCamera().getHeight() * scale;
        float offsetX = pref.x * scale;
        float offsetY = pref.y * scale;
                
        cont.setLocalTranslation(width - offsetX, height + offsetY, 0);
        
        log.info("********** BEGIN CENTER **********");
        log.info("cont {}", cont.getName());
        log.info("centerX [{}] centerY [{}]", width, height);
        log.info("prefSize{}", pref);        
        log.info("offsetX [{}] offsetY [{}]", offsetX, offsetY);
        log.info("compPos {}", cont.getLocalTranslation());
        log.info("********** END CENTER **********");
    } 

I have a vague memory of doing the dialog code and strange code appearing to work.

https://github.com/jayfella/jme-jfx-11/blob/master/src/main/java/com/jayfella/jme/jfx/JavaFxUI.java#L270

Seems wrong to me.

I could have sworn there used to be more than a single issue on this project… Specifically, I remember adding information a crash problem on osx because it is trying to initialize the osx menu bar.

You did. The repository was deleted and re-added. I guess the issues are not part of the repository itself.

Ahhh, okay good. I thought I was going crazy there for a second.

@mitm, yes, that’s expected behavior for most libraries - in this case, @jayfella’s showDialog() implementation (as you can see in the section he pasted) is supposed to handle centering it.

@jayfella, I’ll open an issue about this. I should have some time later today to hunt for a fix - if I find anything I’ll send a PR. I’ve had issues with this since some time back, and if I recall correctly (a big if!) the getBoundsInParent() can be problematic on a newly added child node if a layout pass has not been performed (since the bounds would probably start zeroed). I could easily be totally wrong here, but I’ll probably start by binding to the bounds and watching for changes - in any case, the code above will only work if the dialog node does not change shape after being added.

1 Like

Ill look into the reported issues most likely tomorrow. I’m still moving house so time tends to get eaten at random.

1 Like

Oh fun! Good luck with that… we moved several months ago and have another move coming up in a month or so (this time to a permanent home!).

Ok, I inserted this code right above the call to showDialog():

alert.boundsInParentProperty().addListener((prop, oldBounds, newBounds) -> {
    alert.setLayoutX(screenWidthProperty.get() * 0.5 - newBounds.getWidth() * 0.5);
    alert.setLayoutY(screenHeightProperty.get() * 0.5 - newBounds.getHeight() * 0.5);
});

It centers perfectly. I’ll try moving this to showDialog() and see how it goes.

(The screen width/height properties are JavaFX properties in my own code that track the screen width/height respectively.)

Works like a charm. PR is on its way! :wink:

2 Likes

Thanks Dan. I’m sure it’s fine but I’ll give it a test anyway tomorrow before I merge.

1 Like