• 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
NSUndoManager & NSTableView editing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSUndoManager & NSTableView editing


  • Subject: NSUndoManager & NSTableView editing
  • From: Pete Yandell <email@hidden>
  • Date: Thu, 26 Sep 2002 15:42:16 +1000

I'm trying to work out how to get an NSUndoManager to behave properly in a particular situation:

I have an NSTableView with a single column of text. Rows in the NSTableView are editable. (An undo event for each edit is registered in my data source's tableView:setObjectValue:forTableColumn:row: method.)

I have a button below the NSTableView that lets you add a row. (An undo event for adding the row is registered by the button's action method.)

A problem occurs when you do this: double click a row to edit it, change the text, then click the button to add a row. The edited row is changed and a new row is added, but the undo events for both these things are grouped together because they both occur within the one runloop. Choosing Undo in the Edit menu will then undo both in one hit, whereas they should be separate undo events.

What's the recommended way for getting around this? Do I:

a) use setGroupsByEvent:NO on my NSUndoManager and do any event grouping manually? Seems like that could get painful pretty quickly, but I haven't written much code for the undo manager yet, so I'm not sure how painful.

b) call endUndoGrouping in my tableView:setObjectValue:forTableColumn:row: to forcibly end the group created for this runloop by the NSUndoManager? Would I then have to create another group? This seems kludgy: I shouldn't end a group that someone else has started, and vice versa.

c) create a new undo group for each of my individual undo events? Will this even work, or will the groups be absorbed by the higher level group?

d) perform some other magic trick that I haven't heard of? :)

Anybody have any thoughts? Given that this should be a relatively common case to handle I'm hoping someone out there has worked out the right way to handle it!

Pete Yandell
http://pete.yandell.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSUndoManager & NSTableView editing
      • From: James DiPalma <email@hidden>
    • Re: NSUndoManager & NSTableView editing
      • From: Bill Cheeseman <email@hidden>
  • Prev by Date: NSSocketPortNameServer problem
  • Next by Date: Switcher ( was Re: Book-OT )
  • Previous by thread: Re: NSSocketPortNameServer problem
  • Next by thread: Re: NSUndoManager & NSTableView editing
  • Index(es):
    • Date
    • Thread