Ending NSTableView editing via textDidEndEditing
Ending NSTableView editing via textDidEndEditing
- Subject: Ending NSTableView editing via textDidEndEditing
- From: "K. Darcy Otto" <email@hidden>
- Date: Wed, 13 Jun 2007 08:25:07 -0700
I am trying to have my NSTableView set up so that editing is
terminated when the user hits return. Now, there is much advice
dispensed on this topic, and I have sifted through most of it, but it
is still not working. So far, I have subclassed the NSTableView in
accordance with suggestions on the list (code below), but it appears
the textDidEndEditing is not being called. A few questions:
(i) am I setting up the subclass properly?
(ii) do I need to do anything to get textDidEndEditing called by
NewNSTableView, or should it be called automatically?
Any help would be appreciated.
Code:
(From NewNSTableView.h):
@interface NewNSTableView : NSTableView {
}
- (void) textDidEndEditing: (NSNotification *) notification;
@end
(From NewNSTableView.m):
#import "NewNSTableView.h"
@implementation NewNSTableView
// make return and tab only end editing, and not cause other cells to
edit
- (void) textDidEndEditing: (NSNotification *) notification
{
NSLog(@"!!!!!!!!!!!!!!!!!!!!!!!!!!"); // This is how I know it's not
being called
NSDictionary *userInfo = [notification userInfo];
int textMovement = [[userInfo valueForKey:@"NSTextMovement"]
intValue];
if (textMovement == NSReturnTextMovement
|| textMovement == NSTabTextMovement
|| textMovement == NSBacktabTextMovement) {
NSMutableDictionary *newInfo;
newInfo = [NSMutableDictionary dictionaryWithDictionary:
userInfo];
[newInfo setObject: [NSNumber numberWithInt:
NSIllegalTextMovement]
forKey: @"NSTextMovement"];
notification =
[NSNotification notificationWithName: [notification name]
object: [notification object]
userInfo: newInfo];
}
[super textDidEndEditing: notification];
[[self window] makeFirstResponder:self];
} // textDidEndEditing
(From AppController.h):
#import <Cocoa/Cocoa.h>
#import "NewNSTableView.h"
@interface AppController : NSObject
{
IBOutlet NewNSTableView *tableView;
NSMutableArray *names, *times, *status, *types;
}
Here is where I found the code for textDidEndEditing:
http://www.borkware.com/quickies/single?id=213
_______________________________________________
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