As you can see in the drawing above, I have a stackpane containing two elements, a BorderPane (which again contains a canvas and a statusbar) and another stackpane (which contains some other UI things).
I'd like to be able to click through from invisible areas of the green stackpane to the yellow borderpane but still allow clicking on actual UI stuff on the green stackpane (where there is clickable things like buttons etc.).
How do you do this?
You can use
stackPane.setPickOnBounds(false);
. This means that the stack pane will only be identified as the target of a mouse action if the point on which it was clicked was not transparent (instead of the default behavior, which is to identify it as the target of the mouse action if the mouse click is within its bounds).Here is an SSCCE:
Note that the top stack pane seems unnecessary, as you could simply add the UI elements it contains directly to the underlying stack pane. The previous example could simply be rewritten: