We have been working on an application that uses a ScrollPane containing an AnchorPane that can grow depending on what nodes get placed on the workspace. We are able to place nodes on the workspace and are able to drag them to different positions using mouse drag events.
What I am now trying to implement is a way to automatically scroll the workspace when we are dragging a node and it touches the edge of the visible workspace. I have been able to detect the point when the node begins to move out of the visible area and I am able to move the scroll bar by setting the vvalue or hvalue depending on whether the node has moved vertically or horizontally. This is working to a certain extent.
When I move a node off to the right and update the hvalue, the workspace is scrolled, the device shifts to the left but the mouse stays where it was meaning that the cursor is now not over the node that is being dragged. I have been trying to find a way to shift the cursor position by the same distance that we have scrolled so that it remains in the same position relative to the node that is being dragged.
I have been searching for information about how to do this and reading the Javadocs to try to find a solution without any success. Can someone please advise how to achieve this? Thanks.