Let’s say that I have drawn a square on the screen using the following code:
I want that if the user clicks on the shape, a border with four small boxes (north, south, east and west) is drawn on the shape. Hovering on any of the small boxes changes the cursor to the resize cursor and, if the user drags the small box to a new location, the shape is resized.
How can this be done please?
Instead of using
drawRect()method createShapeobject for the rectangle and draw theShape. ForShapeyou can usegetBounds()to get main rectangle. Use the bounds to find the small boxes rectangles (also Shapes).When mouse is moved (or dragged) check whether one of the boxes shapes contains the mouse event coordinates.
On drag you can change original
ShapeusingAffineTransfrorm.