undo-redo

JTextArea setText() & UndoManager

[亡魂溺海] 提交于 2019-12-17 19:54:14
问题 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

How does undo/redo basically work on iPhone OS?

做~自己de王妃 提交于 2019-12-17 10:31:43
问题 My app doesn't use Core Data yet. Is it true that I must use Core Data for undo/redo? And: How does the user do the undo/redo? I've never seen it in action, and never ever used it. Don't know how I should do it if I wanted to. There's no undo/redo button anywhere. Yet they say it has undo/redo. So how does the user trigger this? 回答1: iPhone OS 3.0 brought over the concept of NSUndoManager from the Mac, which is what enables undo on the iPhone. NSUndoManager maintains a stack of NSInvocations

NSInvocation for Dummies?

痞子三分冷 提交于 2019-12-17 02:04:49
问题 How exactly does NSInvocation work? Is there a good introduction? I’m specifically having issues understanding how the following code (from Cocoa Programming for Mac OS X, 3rd Edition ) works, but then also be able to apply the concepts independently of the tutorial sample. The code: - (void)insertObject:(Person *)p inEmployeesAtIndex:(int)index { NSLog(@"adding %@ to %@", p, employees); // Add inverse of this operation to undo stack NSUndoManager *undo = [self undoManager]; [[undo

NSInvocation for Dummies?

本秂侑毒 提交于 2019-12-17 02:04:10
问题 How exactly does NSInvocation work? Is there a good introduction? I’m specifically having issues understanding how the following code (from Cocoa Programming for Mac OS X, 3rd Edition ) works, but then also be able to apply the concepts independently of the tutorial sample. The code: - (void)insertObject:(Person *)p inEmployeesAtIndex:(int)index { NSLog(@"adding %@ to %@", p, employees); // Add inverse of this operation to undo stack NSUndoManager *undo = [self undoManager]; [[undo

Android Drawing, Erasing and Undoing Action

蹲街弑〆低调 提交于 2019-12-13 16:30:21
问题 Here is the code for Drawing and Undoing but unable to join with Erasing. It is either Drawing + Erasing or Drawing + Undoing but cannot three of these. public class Drawing extends View { private Paint mPaint, mBitmapPaint; private Bitmap mBitmap; private Canvas mCanvas; private Path mPath; private float mX, mY; private static final float TOUCH_TOLERANCE = 4; private int color, size, state; private ArrayList<Path> paths = new ArrayList<Path>(); private ArrayList<Path> undonePaths = new

Asking for undo/redo events in html/javascript

房东的猫 提交于 2019-12-13 15:26:25
问题 I have an interactive html5 canvas thing where sometimes users will want to undo their actions. I have the logic for doing that implemented, but I'm not sure of how to properly catch the "user wants to undo" event. Currently, I just listen to keyboard events and interpret "CTRL+Z" as a request-to-undo, like this: document.addEventListener("keydown", e => { const Z_KEY = 90; let isUndo = e.keyCode == Z_KEY && e.ctrlKey && !e.shiftKey; if (isUndo) { restore(revision.undo()); } }); The problem

Any TextBox control for WinForms with multi level undo feature?

帅比萌擦擦* 提交于 2019-12-13 04:52:02
问题 I've searched half a day, and found none. Do you happen to know there's one? Thanks! 回答1: Its not built in but you can implement your own Take look to this post in stack over flow C#: How to implement good and efficient undo/redo functionaly for a TextBox 回答2: you can implement custom undo feature in textbox .... you can handle the TextChanged event and just push the textbox contents onto a stack each time it changes, then pop and refresh the TextBox every time the user hits Ctrl-Z..... 来源:

Ace Editor Pause/Disable UndoManager

谁都会走 提交于 2019-12-13 03:34:24
问题 Is there any way to remove specific stack value from UndoManager OR any function to pause/disable and start/enable UndoManager again. I want not to push specific data to UndoManager's stack . 回答1: It is not possible to simply not push deltas to the stack, since in that case undoing previous deltas won't be possible, you need to also transform the deltas around skipped delta. Say if you have a document "xyz" to which {insert, 2, "a"} is applied to obtain "xyaz" and then {insert, 1, "b"} to get

How to apply Undo and Redo operation to EditText on Button click in android

荒凉一梦 提交于 2019-12-12 15:09:43
问题 I am trying to apply Undo and Redo operation while writing or applying effect to my EditText. For that i have downloaded class from this Link and then i have used it like this in my app. For Undo TextViewUndoRedo mTextViewUndoRedo = new TextViewUndoRedo(edtNoteDescription); mTextViewUndoRedo.undo(); For Redo TextViewUndoRedo mTextViewUndoRedo = new TextViewUndoRedo(edtNoteDescription); mTextViewUndoRedo.redo(); But i don't know why this code does not work, I have put the log and check whether

Undo / redo not working properly and painting after zoom not working properly too

心已入冬 提交于 2019-12-11 11:14:06
问题 I am trying to implement a paint bucket tool with undo and redo functionality. The issue is that undo and redo are working properly the first time, but when I do undo redo multiple times, the code fails. Can anyone help me figure the issue out? Also zoom is working, but painting after zoom does not work correctly. This is my complete code. You can just copy paste and it will work at your end. <!DOCTYPE html> <html> <head> <title>Painitng</title> <style> body { width: 100%; height: auto; text