• 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: trapping enter/tab on NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: trapping enter/tab on NSTableView


  • Subject: Re: trapping enter/tab on NSTableView
  • From: Ondra Cada <email@hidden>
  • Date: Wed, 20 Mar 2002 08:52:50 +0100

On Wednesday, March 20, 2002, at 06:52 , James Gregurich wrote:

What is the proper technique for intercepting the enter and tab keys on a cell that is being edited in a table view?

Should be FAQ too, I guess ;)

There is AFAIK none but a hack, courtesy of ... well, I don't know who, for shame!

=== forwarded ===
From: email@hidden
Date: Sat Feb 02, 2002 03:18:35 Europe/Prague
To: email@hidden, email@hidden
Subject: Re: sorry for repeating it, NSTableView and *not* selecting the next line?

The only way that I have found to do this is by subclassing NSTableView. (btw, you can search these messages and omnigroup's at cocoa.mamasam.com). Anyways, this is the code that someone suggested to use in your subclass (you just override this one method). It works for me, but I haven't looked at it hard to find anything wrong with it...

- (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;
NSNotification *newNotification;

newUserInfo = [NSMutableDictionary dictionaryWithDictionary:[notification userInfo]];
[newUserInfo setObject:[NSNumber numberWithInt:NSIllegalTextMovement] forKey:@"NSTextMovement"];
newNotification = [NSNotification notificationWithName:[notification name] object:[notification object] userInfo:newUserInfo];
[super textDidEndEditing:newNotification];

// For some reason we lose firstResponder status when when we do the above.
[[self window] makeFirstResponder:self];
} else {
[super textDidEndEditing:notification];
}
}
---
Ondra Cada
OCSoftware: email@hidden http://www.ocs.cz
2K Development: email@hidden http://www.2kdevelopment.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.
References: 
 >trapping enter/tab on NSTableView (From: James Gregurich <email@hidden>)

  • Prev by Date: Re: Coordinate system question
  • Next by Date: Getting info from outside drawRect
  • Previous by thread: trapping enter/tab on NSTableView
  • Next by thread: Further scripting mysteries
  • Index(es):
    • Date
    • Thread