• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: undo in a sheet
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: undo in a sheet


  • Subject: Re: undo in a sheet
  • From: mmalcolm crawford <email@hidden>
  • Date: Wed, 17 May 2006 00:52:20 -0700


On Apr 29, 2006, at 9:24 PM, R. Matthew Emerson wrote:

The instruments are displayed in a table view. A button runs a sheet to edit the calibration data of the selected instrument in a table view. When the sheet is running, the undo menu item is dimmed, so I can't undo object insertions/deletions/edits while the sheet is running. When the sheet is closed, the undo menu item is enabled again, and selecting undo will undo the changes made in the sheet one by one, but of course, you can't see this unless you run the sheet again.
How can I make (Core Data's) undo work in the sheet?


It seems that there's a bug in the way NSApplication processes action events when a sheet is being displayed.

To get this to work properly, you have to subclass NSApplication an override

- (id)targetForAction:(SEL)anAction to:(id)aTarget from:(id)sender
and
- (BOOL)sendAction:(SEL)anAction to:(id)theTarget from:(id)sender


I've extended the example from the NSPersistentDocument Core Data Tutorial to include using a sheet to add new Employee objects. As a further twist, the sheet controller is separated out and uses its own managed objet context -- in this way, edits made in the sheet are kept isolated from those made in the document, and so can easily be discarded if the user cancels the Add operation.


The source code is available at:
<http://homepage.mac.com/mmalc/CocoaExamples/ DepartmentAndEmployees2.zip>


mmalc

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: coredata framework daemon-safe?
  • Next by Date: Re: coredata framework daemon-safe?
  • Previous by thread: Re: Authentication & suid tool
  • Next by thread: NSMenuItem
  • Index(es):
    • Date
    • Thread