Re: NSTableView: detecting key input when NOT editing?
Re: NSTableView: detecting key input when NOT editing?
- Subject: Re: NSTableView: detecting key input when NOT editing?
- From: Eric Forget <email@hidden>
- Date: Wed, 03 Mar 2004 01:01:08 -0500
Hi Alessandro,
>
i have searched the archives a bit but didn't find what i need. i am
>
trying to make that when <return> or <enter> are typed while browsing
>
my tableView, i can do something special. have been searching up to
>
NSResponder for some callback or notifier, no success. where's the
>
trick? thank you!
This is very easy. Insert the following in your subclass of NSTableView:
- (void)keyDown:(NSEvent *)theEvent
{
NSString *characters = [theEvent characters];
BOOL handled = NO;
if (([characters length] == 1) && ![theEvent isARepeat]) {
unichar ch = [characters characterAtIndex:0];
switch (ch) {
case NSNewlineCharacter:
case NSCarriageReturnCharacter:
case NSEnterCharacter:
// Add you stuff here...
// Specify whether super needs to be called
handled = YES || NO; // Choose for your needs
break;
}
}
if (!handled) {
[super keyDown: theEvent];
}
}
Eric
___________________________________________________________________
Eric Forget Cafederic
email@hidden <
http://www.cafederic.com/>
Fingerprint <86D5 38F5 E1FD 5D9C 71C3 BAA3 797E 70A4 6210 C684>
_______________________________________________
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.