0
votes

I was wondering whether it is possible to attach the mouse click signal to a cairo object. Let us suppose I have 3 circles on a drawing, all separate objects. I would then like to change the colour of the ones on which I click. I guess, I could just take the coordinates of the mouse pointer, go through all objects, and see which one is closest. It could be OK for regular objects, but might become a bit unwieldy for hand-drawn lines. So, my question is, is there an elegant way of finding out on which object the user clicked? I was thinking that one could perhaps attach the mouse signal when one draws the objects, and then just return the object name, whenever there is a mouse click. I am using pygtk, but I think the answer should not be specific to the actual language binding.

Cheers,

v923z

1

1 Answers

0
votes

Cairo just paints, it doesn't keep track of where the painted objects are. So the answer is no. You'll have to keep track in your own code of where each object is. I would recommend using a canvas library such as GooCanvas, this is more suited to the job you describe.