undo-redo

JTextArea setText() & UndoManager

我们两清 提交于 2019-11-28 11:42:47
I'm using an UndoManager to capture changes in my JTextArea . The method setText() however deletes everything and then pastes the text. When I undo I firstly see an empty area and then it would show which text it had before. How to reproduce: Run the following code Click the setText() button Press CTRL+Z to undo (you'll see an empty textarea!) Press CTRL+Z to undo (you'll see the actual previous text) I want to skip 3). import javax.swing.AbstractAction; import javax.swing.JFrame; import javax.swing.JTextArea; import javax.swing.KeyStroke; import javax.swing.event.UndoableEditEvent; import

UndoManager support in Firefox

无人久伴 提交于 2019-11-28 10:12:37
问题 I'm a little confused about how to use undoManager in Firefox. According to Mozilla, Firefox 20 now has support for it, but I can't figure out where. I've checked under document , Objects , etc., but can't find it anywhere. I'm sure I'm missing something obvious, so can anyone help? 回答1: You have to set the "dom.undo_manager.enabled" preference to use it, so far, since the spec is still in flux. 来源: https://stackoverflow.com/questions/15888611/undomanager-support-in-firefox

In Chrome undo does not work properly for input element after contents changed programmatically

本秂侑毒 提交于 2019-11-28 04:38:18
问题 In Chrome, I noticed that undo does not work properly for input element after the contents of the element has been changed programmatically. Although I get different behaviours for different browsers, they're not as bad as Chrome. FF20 good IE9 some support (undo stack cleared when input loses focus) Safari5 some support (undo stack cleared when input loses focus) Chrome26 unreliable For example, a script that trims spaces (see also jsfiddle below) type some spaces before "hello!", click

How to implement good and efficient undo/redo functionality for a TextBox

删除回忆录丶 提交于 2019-11-28 04:32:13
I have a TextBox which I would like to implement undo/redo functionality for. I have read that it might have some slight undo functionality already, but that it is buggy? Anyways, I would like to implement both undo and redo functionality also just to learn how you would go ahead and do that. I have read about the Memento Pattern and looked some on a Generic Undo/Redo example on CodeProject. And the pattern kiiind of makes sense. I just can't seem to wrap my head around how to implement it. And how to do it effeciently for the contents of a TextBox . Of course I could just store textbox.Text

How can you add a UIGestureRecognizer to a UIBarButtonItem as in the common undo/redo UIPopoverController scheme on iPad apps?

余生长醉 提交于 2019-11-28 03:08:45
Problem In my iPad app, I cannot attach a popover to a button bar item only after press-and-hold events. But this seems to be standard for undo/redo. How do other apps do this? Background I have an undo button (UIBarButtonSystemItemUndo) in the toolbar of my UIKit (iPad) app. When I press the undo button, it fires it's action which is undo:, and that executes correctly. However, the "standard UE convention" for undo/redo on iPad is that pressing undo executes an undo but pressing and holding the button reveals a popover controller where the user selected either "undo" or "redo" until the

“Undo” history button clear after run macro excel

亡梦爱人 提交于 2019-11-28 01:02:37
I have a macro that fires on the "Worksheet_SelectionChange" event. The macro validate data of one column, it changes the background color of the cell if its wrong. The problem is after run the macro, it clears the history of changes (Ctrl Z) of all the document, even the history changes of other cells that I didnt validate. How can I solve this problem? Thanks. As the others have stated, there is not way to stop a worksheet-changing macro from clearing the undo stack. As another side-effect, you can't undo the macro either without writing your own Undo routine, which can be a huge hassle.

How to design undo & redo in text editor?

匆匆过客 提交于 2019-11-27 21:23:33
Part of my project is to write a text editor that is used for typing some rules, compiling my application and running it. Writing compiler was end and release beta version. In the final version we must add undo and redo to the text editor. I use a file and save it periodically for the text editor. How to design undo and redo to my text editor? What is changed in the structure of persistent of file? Jordão You can model your actions as commands , that you keep in two stacks. One for undo, another for redo. You can compose your commands to create more high-level commands, like when you want to

How to implement 'undo' operation in .net windows application?

感情迁移 提交于 2019-11-27 18:37:52
Assume that, a win form has certain input fields and user enters/re-enters some data. How to retain data previously entered by 'undo' operation? Just I want to know the best way to accomplish it. There are a few options. The important thing is that you start designing it in early in the project. Trying to add it to an existing project can be very expensive if it wasn't designed with this capability in mind. There are a few fundamental patterns that you'll want to take advantage of: MVC or Observer pattern. The first key isn't so much the religious or pattern-zealot implementation of your high

data structure used to implement UNDO and REDO option

可紊 提交于 2019-11-27 10:23:47
I want to implement UNDO and REDO option(as we see in MS word etc). Can you suggest me a data structure for it, and how can i implement it.? It isn't a data structure but a design pattern. You're looking for the Command Pattern . The standard is to keep the Command objects in a stack to support multi level undo. In order to support redo, a second stack keeps all the commands you've Undone. So when you pop the undo stack to undo a command, you push the same command you popped into the redo stack. You do the same thing in reverse when you redo a command. You pop the redo stack and push the

How can you add a UIGestureRecognizer to a UIBarButtonItem as in the common undo/redo UIPopoverController scheme on iPad apps?

微笑、不失礼 提交于 2019-11-27 05:04:42
问题 Problem In my iPad app, I cannot attach a popover to a button bar item only after press-and-hold events. But this seems to be standard for undo/redo. How do other apps do this? Background I have an undo button (UIBarButtonSystemItemUndo) in the toolbar of my UIKit (iPad) app. When I press the undo button, it fires it's action which is undo:, and that executes correctly. However, the "standard UE convention" for undo/redo on iPad is that pressing undo executes an undo but pressing and holding