How to get the coordinates of the mouse position relative to the node network grid

Hi,

I want to get mouse position in network editor, such operator position. I use ui.pans[0].x/y and miuse in(Absolut) to caculate, But the numerical mapping is wrong.

Is there any way to achieve it? Thanks

1 Like

I have no idea if this is possible in the 1 step elegant way you are hoping for - would be sweet! However, you might be able to in a very annoying round about way, calculate the position in graph space by transforming your absolute mouse coordinates from the raw coordinates into the desired coordinate space.

For instance, something like this:

  1. absolute windows desktop x/y
  2. x/y coords relative to entire TD window
  3. x/y coords relative to a specific TD pane
  4. x/y coords relative to the zoom/offset of a network pane’s graph.

1 is easy, already have that. 2 is possible, though not simple. can use python ctypes library to access windows and their positions, etc. 3 is maybe not possible, though you can maybe assume certain fixed offsets from the TD window if your environment is pretty controlled. 4 is possible.

@lucasm’s solution just might work but is certainly a huge pain.

What are you trying to achieve… maybe there is a more straightforward way.

1 Like

Thanks!!!
I used the fourth method to remap the mouse position before, but when I zoom the grid, I have to click the mouse and drag again to refresh the data.
01

1 Like

hey @Zink would you mind sharing your solution? can’t wrap my brain around this one. just the python or the equation would be fine - don’t need a tox (unless you’d prefer to share that).