I started playing around with JavaFX over the weekend, and I'm exploring the capabilities of collision detection. I want to setup a program where I can either click and drag a shape around a scene, or use the keyboard to move the shape around, and detect collisions. I can handle the mouse event and see the shape moving around, but when I add an EventHandler<KeyEvent> to the scene at the same point as my mouse handler it's not getting fired.
I thought my problem might be that I need to not attach the event handler to a node, maybe to the root or something, but I found Oracle's
example of a keyboard and they are attaching events to scene graph objects.
There must be something obvious I'm doing wrong here. Can anyone give me a hand by pointing it out?
Thanks!
I created a custom shape (just two circles joined by a line) and a scene that contains that shape + another shape for it to collide with.
Then I create my scene somewhat like so: