• 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: NSTableView: detecting key input when NOT editing?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >NSTableView: detecting key input when NOT editing? (From: Alessandro Volz <email@hidden>)

  • Prev by Date: Re: NSTableView: detecting key input when NOT editing?
  • Next by Date: Re: Changing NSTableView cell editing behaviour
  • Previous by thread: Re: NSTableView: detecting key input when NOT editing?
  • Next by thread: NSEditor, NSEditorRegistration Protocols
  • Index(es):
    • Date
    • Thread