• 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
NSOutlineView - Trouble validating edits
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSOutlineView - Trouble validating edits


  • Subject: NSOutlineView - Trouble validating edits
  • From: Lon Giese <email@hidden>
  • Date: Sun, 28 May 2006 02:26:35 -0700

What is the proper way to validate edits?  It seems simple enough

I want the user to edit a file name in the outline and if the file name is not acceptable then continue editing the same cell.
This works fine with my code if the user ends editing by hitting tab, return or enter.
But if the user clicks on another row during editing, editing ends and the user is able to select another row.


Why is the editing behavior of NSOutlineView different when the user clicks another row? Is this a bug or some sort of feature?

Also, while trying to come up with a work around, I noticed that the outline view does not seem to call the table view delegate methods, (the outline view's delegate methods are called correctly) namely:
// this is not getting called for some reason - does outline view call table view delegate methods?
-(BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
editing = YES;
return YES;
}


This is the code that works fine when the user hits tab, return, or enter, but when the user clicks another row editing ends.
- (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
NSString *identifier = [tableColumn identifier];
// the item returns NO if new value is unacceptable
if( [item setObjectValue:object forIdentifier:identifier] )
{
[outlineView reloadItem:item]; // value was changed
}
else
{
// stop the outline from editing the next row - put it back so user can fix it
int row = [outlineView rowForItem:item];
int column = [outlineView columnWithIdentifier:identifier];
[outlineView selectRow:row byExtendingSelection:NO]; //deprecated, but still works
[outlineView editColumn:column row:row withEvent:nil select:YES];
}
}
_______________________________________________
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: Write an NSString or NSMutableString to a Text file
  • Next by Date: Re: Alternatives to NSMatrix and NSTable?
  • Previous by thread: Re: Write an NSString or NSMutableString to a Text file
  • Next by thread: NSBrowser with custom cells
  • Index(es):
    • Date
    • Thread