NSImageView 和 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 Rob 在此处发布的解决方案。
但它一次只处理一个手势。如果您严格处理变换和中心(用于平移),那么如果您不允许同时平移、旋转、捏合,您应该可以接受他的解决方案。如果同时进行捏合和旋转,如果使用变换,您只需在开始时设置变换一次,并处理谁先设置它,这样其他手势就不会设置原始变换。
我正在研究一种将多个属性封装到字典中然后撤消/重做的方法,尽管需要一种将该字典复制到撤消/重做堆栈的方法,请参阅 这个问题
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