Kymera Map module mouse events

We recently purchased the map module and I am having difficulty understanding what’s happening with mouse coordinates in the “onPointEntered” extension function.

You can see in the pictures below that the mouse event.x and event.y for the onPointEntered event do not match the x and y coordinates from the components mousePressed event. I wouldn’t expect them to match exactly but the onPointEntered coords don’t seem to make any sense unless they are relative to unknown sub-components of the map container.

To get the results in the screen grabs I used this script in the components’ mousePressed event handler:

event.source.parent.getComponent('Label 1').text = "Map X: %s, Y: %s" % (event.x, event.y)

and this script in the onPointEntered extension function:

self.parent.getComponent("Label 2").text = "Point X: %s, Y: %s" % (event.x, event.y)

Am I misunderstanding what is supposed to be happening? If so, how do I translate the onPointEntered coordinates to useful coordinates so that I can display a popup at that location?

I was able to get the desired screen coordinates by using the convertMouseEvent method from SwingUtilities.

from javax.swing.SwingUtilities import convertMouseEvent
container = self.parent.getComponent("Container Details Overlay")
convertedEvent = convertMouseEvent(event.source, event, container)
x = convertedEvent.getX()
y = convertedEvent.getY()
system.gui.moveComponent(container , x, y)

I tried this yesterday before I made the original post but I must have had something wrong.

And after that I figured out that the point reference has an x and y property that can be directly accessed and those coordinates are relative to the map component itself. I took the long way around it looks like but the convertMouseEvent bit will be useful to me in another situation at least. 8)

So my final script is now (omitting some math for intelligent positioning):

container = self.parent.getComponent("Container Details Overlay")
system.gui.moveComponent(container, point.x, point.y)

Hi JDJohnson. Thanks for making use of our Map Module. Positions returned in the relevant events (onPointEntered, onShapeEntered, ect.) are relative to the sub-component that invokes them (that is to say, the points/shapes themselves). Which means, as you found, you have to convert the position to be relative to the map panel.

Sorry for any confusion that this may have caused.