• 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: Sorting a TableView in tableView:setObjectValue:forTableColumn:row:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting a TableView in tableView:setObjectValue:forTableColumn:row:


  • Subject: Re: Sorting a TableView in tableView:setObjectValue:forTableColumn:row:
  • From: Ondra Cada <email@hidden>
  • Date: Sat, 12 Oct 2002 14:16:23 +0200

On Saturday, October 12, 2002, at 06:16 , Andreas Mayer wrote:

Never mind that, it it does not, just postpone it to the end of the event,

Nice idea. But that only kind-of works.

Normally the next (or previous or whatever) cell would be selected for editing. This method selects the current row regardless of the way the editing ended and I do not know what cell to select for editing either. I would have to look at what textDidEndEditing: changed. I think that's even more complicated than doing it myself in the first place.

Aha, I see.

Well, IMHO there are two reasonable ways:

(i) switch off edit mode when the user's done with a cell. So far as I know, there's no clean way to do that, but this (posted by someone ages ago here) seems to work reliably and without ugly sideeffects:

// this dirtie changes the editing behaviour NOT to select the next line if Enter gets pressed
@interface ExtraSelectionTableView:NSTableView @end
@implementation ExtraSelectionTableView
-(void)textDidEndEditing:(NSNotification*)notification {
if ([[[notification userInfo] objectForKey:@"NSTextMovement"] intValue]==NSReturnTextMovement) {
// This is ugly, but just about the only way to do it. NSTableView is determined to select and edit something else, even the text field that it just finished editing, unless we mislead it about what key was pressed to end editing.
NSMutableDictionary *newUserInfo=[NSMutableDictionary dictionaryWithDictionary:[notification userInfo]];

[newUserInfo setObject:[NSNumber numberWithInt:NSIllegalTextMovement] forKey:@"NSTextMovement"];
[super textDidEndEditing:[NSNotification notificationWithName:[notification name] object:[notification object] userInfo:newUserInfo]];
// For some reason we lost firstResponder status when when we did the above.
[[self window] makeFirstResponder:self];
} else {
[super textDidEndEditing:notification];
}
}
+(void)load {
[self poseAsClass:[self superclass]];
}
@end

(ii) or, by exploiting a similar technique to what I've suggested before, postpone the complete reordering till editing ends.

The thing is that IMHO it would not do to re-order table lines "under user'
s hands" whilst he continues editing: I would consider that a quite bad UI.
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
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: Sorting a TableView in tableView:setObjectValue:forTableColumn:row:
      • From: Andreas Mayer <email@hidden>
References: 
 >Re: Sorting a TableView in tableView:setObjectValue:forTableColumn:row: (From: Andreas Mayer <email@hidden>)

  • Prev by Date: Re: Cocoa Books (was New to Cocoa)
  • Next by Date: Re: { Semi-Newbie } Inverse of +initialize?
  • Previous by thread: Re: Sorting a TableView in tableView:setObjectValue:forTableColumn:row:
  • Next by thread: Re: Sorting a TableView in tableView:setObjectValue:forTableColumn:row:
  • Index(es):
    • Date
    • Thread