• 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 group action name lost in drag operation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undo group action name lost in drag operation


  • Subject: Re: Undo group action name lost in drag operation
  • From: Gabriele de Simone <email@hidden>
  • Date: Tue, 5 Oct 2004 11:32:47 -0400


On Oct 5, 2004, at 10:46 AM, Shaun Wexler wrote:

On Oct 5, 2004, at 6:33 AM, Gabriele de Simone wrote:

In response to a copy-on-drop operation in a NSTableView, I add a number of elements to my model. To my great pleasure I noticed that whatever Cocoa class was processing the drag operation for me was automatically beginning and ending an undo group around my handler (tableView:acceptDrop:row:dropOperation:).

Enlightened by this discovery, I set an action name at the end of my insertions ("Add Items"), and sure enough this action name shows up under the Edit menu as "Undo Add Items". The problems begin when you undo that operation. The action name is lost, and the Redo menu item name takes the name of the last nested action of the undo group.

Now, I did find the following workaround, which basically tells my model objects *not* to set the action name if an undo group is open...

if ([undoManager groupingLevel == 0) {
[undoManager setActionName:@"something"];
}

...but I am interested in knowing whether I am ignoring some basic knowledge on undo grouping action names. A search for "undo group action name lost" brought up nothing on CocoaBuilder.

It's best to set your action name in your controller class, in the action method, etc. In your case where the model is handling the drag/drop, it's okay to set the action name AFTER the drop is completed. You definitely don't want to set action names for the individual array accessor methods in the model. I create a separate API for undoable model actions in the model itself, which set the action name. Your undo invocation should call back into the array accessors, not the separate API.

I may be misunderstanding your suggestion, but there is no controller class where the drag is initiated and terminated from (it's NSTableView, so everything is automatic if you implement a few methods). I will try setting the action name outside tableView:acceptDrop:row:dropOperation:, but my guts tell me that it will require more bookkeeping (watch for some kind of drag-finished notification? dig up what kind of operation was completed and set the action name accordingly?)

In my experience I have found it convenient and appropriate to set the action names at the model level, *if* you are also registering the actual undo invocation there. With Bindings, often times there just isn't any other controller/action code to set action names in. Any controllers that sit above the model can still group actions together and give them a better name anyway. The unexpected result here is that the action name is lost.

Gabriele

_______________________________________________
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
References: 
 >Undo group action name lost in drag operation (From: Gabriele de Simone <email@hidden>)
 >Re: Undo group action name lost in drag operation (From: Shaun Wexler <email@hidden>)

  • Prev by Date: Searching an NSArray for objects in NSDictionary
  • Next by Date: RE: Re: fileWrapperRepresentationOfType: is not called
  • Previous by thread: Re: Undo group action name lost in drag operation
  • Next by thread: Searching an NSArray for objects in NSDictionary
  • Index(es):
    • Date
    • Thread