Reputation: 31
What I did today was I right click my First Responder and saw all the Received Actions. What amused me was there were some additional methods Undo ,Redo ,Go Back ,Go Forward I placed a UIbutton in my UI and connect it to Undo and when I ran the app and clicked on the UIButton nothing happened. Can anyone explain what are these actions for is there any method I can use these for undo and redo ,instead of NSUndoManger .
Upvotes: 1
Views: 1263
Reputation: 1751
There are predefined menu items when you create an application using xcode. If you check your App's Edit menu, you will find undo and redo in it. The undo action you are talking about gets called when you click undo in these menu items. The NSTextField, NSTextView and some other elements have pre-registered undo-manager. Drag a textfield in your XIB. Then run the application. Then type something in the text field. After that go to the Edit menu of your application, you will see an option for "Undo Typing".
Click this and yes undo works, this is when undo action is called.
Now, get a button in xib. Connect it with undo action of First Responder. Run the application. See the button will work same as the "undo menu item". The button will not work when undo menu item is greyed because undo manager is not registered that time.
Hope this solves your query.
Upvotes: 3