NSImageView and NSUndoManager

340 views Asked by At

I have a image on the view and user can drag and move the image or rotate the image with finger touch.

I want to do Undo the action performed by user.

Like if the image is move to new location and then user press undo button, image should move back to the previous location. Or if user rotates the image and then press undo button it should rotate image to its previous angle.

It would be helpful if I get any sample example for the same.

Thanks in advance

1

There are 1 answers

0
scooter133 On

Check out the Solution that Rob Posted here.

It only deals with one gesture at a time though. If you are dealing strictly with the Transform and the Center (for Pan) then You should be fine with his solution if you do not allow Pan, Rotate, Pinch at the same time. If Pinch Pinch and Rotate at the same time, if working with a Transform you just need to set the transform once at the beginning and deal with who sets it first so the other gesture does not set the Original Transform.

I'm working on a way to encapsulate multiple attributes into a Dictionary to then Undo/Redo, though need a way to copy that Dictionary to the Undo/Redo Stack, see this Question