nsundomanager

Registering a redo operation from an async undo with NSUndoManager

我只是一个虾纸丫 提交于 2020-05-30 07:43:45
问题 With UndoManager.registerUndo(withTarget:selector:object:) I can register an undo operation, and in the provided selector calling this same method again causes the registration of a redo operation. This works fine unless in the selector I'm calling an async function which then needs to register the redo operation, like this: func job() { doSomething() registerUndo(self, undo) } func undo() { async { doSomethingElse() registerUndo(self, job) } } In this case, both calls to registerUndo()

Undoing and Redoing NSView Object Move Made by NSPanGestureRecognizer

二次信任 提交于 2020-01-16 08:36:32
问题 I am working on a sample desktop application to test the UndoManager class, which I don't often get to use. Anyway, the following is the idea. I create two NSView sub view objects (red & blue). They are added to an IBOutlet-connected NSView object (panView). I add the pan gesture ( NSPanGestureRecognizer ) to these two sub view objects. The applications calls the undo manager when the user moves either sub view object. The following is my entire code from top to bottom. import Cocoa class

NSUndoManager : separate multiple changes in one run loop cycle

…衆ロ難τιáo~ 提交于 2020-01-14 13:35:32
问题 I'm using [undoManager registerUndoWithTarget::] to add some changes to undo stack. However, sometimes happens, when in one run loop cycle two changes added to the same group, so they are reverted at once, which is not behavior I'd like to have. I want to separate these two changes to have two items in undo stack. How to correctly implement this? Use [NSObject performSelector: ] to call second undo addition in the next run loop cycle, or whatever else? Thanks. 回答1: As you’ve noticed, by

can't get wxHaskell to work from ghci on Mac

佐手、 提交于 2020-01-02 03:40:19
问题 I'm trying to run an example using EnableGUI function. % ghci -framework Carbon Main.hs *Main> enableGUI >> main This is what I get instead of a working program: 2013-01-14 00:21:03.021 ghc[13403:1303] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-945.11/Misc.subproj/NSUndoManager.m:328 2013-01-14 00:21:03.022 ghc[13403:1303] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread. 2013-01-14 00:21:03

How to name Undo menu entries for Core Data add/remove items via bindings and NSArrayController?

Deadly 提交于 2019-12-30 07:41:37
问题 I have a NSTableView populated by a Core Data entity and Add Item / Remove Item buttons all wired with a NSArrayController and bindings in Interface Builder. The Undo/Redo menu items can undo or redo the add / remove item actions. But the menu entries are called only „Undo“ resp. „Redo“. How can i name them like „Undo Add Item“, „Undo Remove Item“, etc. (I am aware, something similar was asked before, but the accepted answers are either a single, now rotten link or the advice to subclass

NSUndoManager: capturing reference types possible?

时光毁灭记忆、已成空白 提交于 2019-12-25 09:26:05
问题 I am having trouble understanding how NSUndoManager captures values when the values are reference types. Whenever try to use the undoManager, the values don't undo. Note: I need to support macOS 10.10, and I am using Swift 3 and XCode 8 Here I save the state of the ID numbers, reset them all to -1, and then try to undo. The result is that they are all still -1. import Cocoa class Person: NSObject { var id: ID init(withIDNumber idNumber: Int) { self.id = ID(idNumber) } } class ID: NSObject {

Using NSUndoManager with prepareWithInvocationTarget, Gestures and Objects

无人久伴 提交于 2019-12-25 08:25:18
问题 I have a Drawing App of sorts. I want to Implement Undo/Redo. Though I'm running into difficulty with storing the Original and New Values for the Undo/Redo. With Gestures I need to store a Few things: transform, Center, for the Properties Dialog, I need to store many more, Color, Font, Font-Size, Outline, Outline Color, the Text It self, etc. I've created a NSMutableDictionary of the Attributes that the user can change in a Single Gesture/Properties Popover. I wanted to use Rob's Answer for

Save NSUndoManager transactions one by one

廉价感情. 提交于 2019-12-25 04:29:19
问题 I need to save changes not only locally into Core Data , but on server too. My concern is, in my case user can do bunch of interaction in a short time. Between interaction there is not enough time to receive success message returned from server. So either I lock the GUI, until next message returns - this is the case now -, or choose a different approach. My new approach would be to let user do many interactions and put transactions onto undo stack provided by NSUndoManager , enabled on