1

My code stops at a breakpoint when I type a certain character, so that I can inspect things in the debugger. (I use an event filter to do this.)

It would be nice to be able to inspect the Node that was under the cursor when I typed the character.

I can’t see how to do this.

Apparently I can use MouseInfo.getPointerInfo().getLocation() to get the cursor x,y, but I can’t see how to go from x,y to the frontmost intersecting Node. I suppose I could maintain a set of all nodes and go through them brute-force, but it seems to me there must be a more elegant solution.

UPDATE

At this question, JavaFX 2.2 get node at coordinates (visual tree hit testing), I found an FX bug report, FX should provide a Parent.pick() routine, which led to another bug report, Make impl_pickNode public., which led to this StackOverflow answer, https://stackoverflow.com/a/16279603/1390116

That trick, however seems to work only when already in a MouseEvent dragged handler. I don't see how that will get me what I need from a KeyEvent handler.

silvalli
  • 295
  • 2
  • 13
  • Possible duplicate [JavaFX 2.2 get node at coordinates (visual tree hit testing)](https://stackoverflow.com/questions/14420569/javafx-2-2-get-node-at-coordinates-visual-tree-hit-testing) – jewelsea Dec 29 '21 at 03:00

0 Answers0