Is there a correct way to solve the problem with event propagation between two sibling panes?
For example we have StackPane with 2 panes inside.
StackPane p = new StackPane();
Region p1 = new Region();
Region p2 = new Region();
p.getChildren().addAll(p1, p2);
p2 in this example capture mouse events and p1 can't react on it even if event is not consumed.
Is there a correct way to propagate event to p1 if it not consumed by p2?
setMouseTransparent not solve my problem because I need that both children elements react on mouse.
Thanks for advise.
Trying this might also work,
EventDispatcher Interface
My problem was partially solved. Maybe I not quite correctly formulate question. I write app like graphic-editor and have tools-layer panes on stackpane with guides, grid, selection-tools etc. and need that children of this layers can handle mouse and panes itself will be transparent for mouse events.
Problem was solved by override pickNode, not in public API, but it work. Maybe help somebody.
By default events will just propagate up the heirarchy and terminate at the root. There are a few approaches you could take to solve your problem.
buildEventDispatchChain.dispatchEvent
). Then do the same on the other side.Just catch the event in an event handler and fire it on the other components:
You can still add mouse listeners on the top components and it works fine. If the bottom component does more fancy stuff with the event, you might need to clone and adjust it. This also works with more than two children.