# Paintable Canvas Question

**URL:** <https://forum.inductiveautomation.com/t/paintable-canvas-question/44421>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [March 12, 2021, 6:19pm UTC](https://forum.inductiveautomation.com/t/paintable-canvas-question/44421 "2021-03-12T18:19:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [March 12, 2021, 6:19pm UTC](https://forum.inductiveautomation.com/t/paintable-canvas-question/44421/1 "2021-03-12T18:19:45Z")

</div>

We have some graphics that are generated through the paintable canvas, and I want to be able to respond to a click event when the user clicks on what has been painted in the canvas.

Basically I’m creating a rectangle and then rotating it. I have a final object named rotateBelt that is of type java.awt.geom.Path2D.Double. It looks like I can then use the contains() method to see if my mouse position is within that path.

Now comes the parts I’m not sure of. How do I share that variable that I generate in the repaint event be available in the mouseMoved or mouseClicked event? I tried monkey patching the event.source object, but things weren’t happy… most likely because they are java objects not python object.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 12, 2021, 6:57pm UTC](https://forum.inductiveautomation.com/t/paintable-canvas-question/44421/2 "2021-03-12T18:57:22Z")

</div>

Hmm. I’m not sure about performance, but you could `putClientProperty(string, obj)` (a Swing mechanism, not an Ignition mechanism) to ‘cache’ the Rectangle you’re creating in `paint`, and `getClientProperty(string)` to retrieve it in the mouse event to run your `contains` check.

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [March 12, 2021, 6:59pm UTC](https://forum.inductiveautomation.com/t/paintable-canvas-question/44421/3 "2021-03-12T18:59:32Z")

</div>

I’m open to anything at this point as I’m just exploring.

I’ll check it out.
