As I see in your code, you create new Rectangle
(rect1
) that is initiated with the values of another Rectangle
(MyRect
). You register the event to rect1
but, the Rectangle
that you add to MyCanvas
is MyRect
.
It looks like you meant to add rect1
to the canvas instead of MyRect
...