简体   繁体   English

NSImageView和NSUndoManager

[英]NSImageView and NSUndoManager

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 提前致谢

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 我正在研究一种将多个属性封装到Dictionary中然后进行Undo / Redo的方法,尽管需要一种将该Dictionary复制到Undo / Redo Stack的方法,请参见此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM