# Kymera Map module mouse events

**URL:** <https://forum.inductiveautomation.com/t/kymera-map-module-mouse-events/10448>\
**Category:** 3rd Party Modules\
**Created:** [September 10, 2015, 3:44pm UTC](https://forum.inductiveautomation.com/t/kymera-map-module-mouse-events/10448 "2015-09-10T15:44:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [September 10, 2015, 3:44pm UTC](https://forum.inductiveautomation.com/t/kymera-map-module-mouse-events/10448/1 "2015-09-10T15:44:11Z")

</div>

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:

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

and this script in the onPointEntered extension function:

```auto
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?

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/52984c622c0ad84982ebeb715a605fdfbbe72b5e.png)  
  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/5/54c962fd7a06c2f92ecf75c9d80ea862f420980c.png)  
  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/fa93776fd3a7e1925c53f365c56931e6bf1c96fd.png)

---

<div class="post-metadata">

**Author:** ![JGJohnson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jgjohnson/32/29582_2.png) [@JGJohnson](https://forum.inductiveautomation.com/u/JGJohnson)\
**Post date:** [September 10, 2015, 7:03pm UTC](https://forum.inductiveautomation.com/t/kymera-map-module-mouse-events/10448/2 "2015-09-10T19:03:09Z")

</div>

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

```auto
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)](https://us1.discourse-cdn.com/inductiveautomation/original/1X/587d7fe0d6822f36e81815ab06aa7164e9d2e057.gif "Cool")

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

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

---

<div class="post-metadata">

**Author:** ![travis.sareault](https://avatars.discourse-cdn.com/v4/letter/t/c5a1d2/32.png) [@travis.sareault](https://forum.inductiveautomation.com/u/travis.sareault)\
**Post date:** [September 11, 2015, 9:31pm UTC](https://forum.inductiveautomation.com/t/kymera-map-module-mouse-events/10448/3 "2015-09-11T21:31:07Z")

</div>

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.
