Re: NSUndoManager & NSTableView editing
Re: NSUndoManager & NSTableView editing
- Subject: Re: NSUndoManager & NSTableView editing
- From: Bill Cheeseman <email@hidden>
- Date: Thu, 26 Sep 2002 06:28:42 -0400
on 02-09-26 1:42 AM, Pete Yandell at email@hidden wrote:
>
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:
>
>
....
>
>
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!
I do it in an analogous row deletion scenario by calling NSControl's
abortEditing. In your situation, you should be able to call NSControl's
validateEditing. Or NSWindow's endEditingFor:. Or possibly NSCell's
endEditing:.
In Jaguar, any command that selects or deselects a row is supposed to do
this for you. So you might also be able to just deselect the row, either
with a specific command to do so, or [self window]makeFirstResponder:[self
window].
The idea is to force the row being edited to end editing gracefully (that
is, by validating its contents in case you have a formatter attached to it
or some other validation technique), before you add the new row.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
Croquet Club of Vermont -
http://members.valley.net/croquetvermont
_______________________________________________
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.