Accessing current mouse coordinates

Hi,

I’m trying to get the current mouse location. I can get the cursor’s absolute position in the window with MouseInfo.getPointerInfo().getLocation(), but that doesn’t match with VASSAL properties like CurrentX and CurrentY. ClickedX and ClickedY only work after a right-click, which I’m desperately trying to avoid here.

So, is there any way to get the window coordinates of any other feature, like the currently selected piece, without adding a custom Java class?

Is there some other way of getting the current mouse coordinates that I’ve missed?

Thanks!

Update: VASSAL.build.module.Map.getMapList() gets me a list of maps. The specific map I want happens to be the first one, so I can do get(0) to get that, get the location of the map with getComponent().getLocationOnScreen(), and adjust for scale with componentToMap().

That means VASSAL.build.module.Map.getMapList().get(0).componentToMap(new Point(MouseInfo.getPointerInfo().getLocation().x - VASSAL.build.module.Map.getMapList().get(0).getComponent().getLocationOnScreen().x, MouseInfo.getPointerInfo().getLocation().y - VASSAL.build.module.Map.getMapList().get(0).getComponent().getLocationOnScreen().y)).x gives me the x-coordiate for the location of my mouse.

The same thing almost works for y, but I’m off by 3 or 4 and I’m not sure why. Well, I assume the “or 4” part is because of rounding, but I’m not sure why I’m off.

This is sloppy, since I really should have the code work for any map. However, I don’t know a one-line way to make BeanShell pull a specific Map out of the list. Of course, my knowledge of Java stops in like 2002.

Pretty sure not. It would be very nice though.