How do I listen for change in the global position of a Node
Hi there,
I want to create a Wire/Connection node between two scene nodes. I want this Wire node to be updated when one of the nodes is moving. In the common scenario I would listen for change events in the target nodes position and update the Wire :
targetNode1.translateXProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue value, Number oldValue, Number newValue) {
wire.setStartX(targetNode1.getTranslateX());
wire.setStartX(targetNode1.getTranslateY());
wire.setEndX(targetNode2.getTranslateX());
wire.setEndY(targetNode2.getTranslateY());
}
});
The problem is that the target nodes are children of another container nodes(that are actually moving). So listening for change events in the translate properties of the target nodes does not work(their parent nodes are actually moving)
Is there way to listent for change in the global position of the target nodes relative to the Scene?