NSTable - intercept item name before user editing
NSTable - intercept item name before user editing
- Subject: NSTable - intercept item name before user editing
- From: Ari Benzane <email@hidden>
- Date: Wed, 6 Jun 2007 23:12:43 +0100
Hi Guys. Can anyone suggest a a non-hackish way to deal with the
following?
My app has a hierarchical outline view of nodes to arbitrary depth,
organized by 'group' and 'node' classes. You can edit the names of
these items directly in the outline view. I just added a requested-
feature to append to a suffix to group names '[n]' where n is the
number of the group children (eg. MyGroup[1]). Here's the code from
my delegate (edited for length)
- (id)outlineView:(NSOutlineView*)pOutlineView
objectValueForTableColumn:(NSTableColumn*)pTableColumn byItem:(id)pItem
{
if ([pItem isGroup] && [[pTableColumn identifier] isEqualTo:
@"name"]) {
return [NSString stringWithFormat: @"%@ [%d]",[pItem name],
[pItem childrenCount]];
} else {
return [pItem valueForKey: [pTableColumn identifier]];
}
}
The problem is, when the user goes to edit the group name, the suffix
is retained so you end up with 'MyGroup[1][1][1]' etc unless you
manually remove it. The prefix needs to be removed before the user
can edit the item. Is there someway I can 'intercept' the string
returned when the user edits the cell, so that's it replaced with the
_actual_ item name, and not the aesthetic prefixed one?
- (void)outlineView:(NSOutlineView*)pOutlineView setObjectValue:(id)
pObject forTableColumn:(NSTableColumn*)pTableColumn byItem:(id)pItem
{
[pItem setValue: pObject forKey: [pTableColumn identifier]];
}
Any help appreciated.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden