实施撤消 [英] Implementing undo

查看:51
本文介绍了实施撤消的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个地图编辑Web应用程序,我们可以在其中创建和编辑折线,多边形等.我在查找有关Web上撤消实施的信息时遇到了一些麻烦,我对我们需要撤消"产生了抱怨.和这是我的使用闭包的命令模式"但我认为在这和完整的撤消/重做界面之间,还有相当长的路要走.

I'm creating a map editing webapp where we can create and edit polylines, polygons etc. I've some trouble finding informations on undo implementation on the web, I find whining about "we need undo" and "here is my Command pattern using closures" but I think between that and a full undo/redo interface there is quite some road.

所以,这是我的问题(我认为是Wiki的不错的候选人):

So, here are my questions (good candidate for wiki I think):

  • 应该管理堆栈,还是可以将命令发送到浏览器的堆栈?(以及如何处理本机命令,例如在这种情况下在textifields中进行文本编辑)
  • 我该如何处理命令压缩"?(命令分组),当某些命令是浏览器本地的
  • 如何检测撤消( ctrl + z )击键?
  • 如果我注册了按键事件,如何确定是否阻止默认事件?
  • 如果没有,我可以在某个地方注册一些撤消事件处理程序吗?
  • 用户不习惯在网络上撤消操作,我该如何训练"操作者?他们来探索/撤消我的应用程序?
  • Should I manage the stack, or is there a way to send my commands to the browser's stack ? (and how do I handle native commands, like text edits in textifields in this case)
  • how do I handle "command compression" (command grouping) when some commands are browser native
  • How do I detect the undo (ctrl+z) keystroke?
  • If I register a keyup event, how do I decide if I prevent default or not?
  • If not, can I register some undoevent handler somewhere ?
  • Users are not used to undo on the web, how can I "train" them to explore/undo on my application ?

推荐答案

您需要具有用于对象创建和删除的功能.然后将这些功能传递给撤消管理器.请参阅我的javascript撤消管理器的演示文件: https://github.com/ArthurClemens/Javascript-Undo-经理

You need to have functions for object creation and deletion. Then pass those functions to the undo manager. See the demo file of my javascript undo manager: https://github.com/ArthurClemens/Javascript-Undo-Manager

演示代码显示画布,但该代码不可知.

The demo code shows canvas, but the code is agnostic.

它不包含键绑定,但是可以帮助您完成第一步.

It doesn't contain key bindings, but may help you with the first steps.

我本人已在Web应用程序中使用此按钮,并在保存旁边带有用于撤消和重做的按钮.

Myself I have used this in a web application with buttons for undo and redo, next to save.

这篇关于实施撤消的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆