Paintable Canvas Question

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.

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.

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

I’ll check it out.