• 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
Making 'return' Begin Editing, like Finder does
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Making 'return' Begin Editing, like Finder does


  • Subject: Making 'return' Begin Editing, like Finder does
  • From: Jerry Krinock <email@hidden>
  • Date: Sun, 3 Feb 2008 15:30:36 -0800

I've implemented the following method in my NSTableView subclass which makes the 'return' key begin editing, like Finder does. It works, but I don't like that hard-coded keycode 0xd for 'carriage return'.

Is there a better way to do this? I tried to implement - insertNewline:, but it never gets invoked.

Thanks,

Jerry Krinock

- (void)keyDown:(NSEvent*)event {
    NSString *s = [event charactersIgnoringModifiers] ;
    unichar keyChar = 0 ;
    BOOL didDo = NO ;
    if ([s length] == 1) {
        keyChar = [s characterAtIndex:0] ;
        if (keyChar == 0xd) {
            // Unless editing is already in process, which is not the
            // case we're trying to handle here, an entire row will
            // be selected and therefore [self selectedColumn] will
            // be the "no selection" indicator, -1. So, we edit column
            // 0.  If the user wants a different column, they can
            // easily tab to it.
            [self editColumn:0
                         row:[self selectedRow]
                   withEvent:nil
                      select:YES] ;
            didDo = YES ;
        }
    }

    if (!didDo) {
        [super keyDown:event] ;
    }
}



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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


  • Follow-Ups:
    • Re: Making 'return' Begin Editing, like Finder does
      • From: Ricky Sharp <email@hidden>
  • Prev by Date: Re: receiving a file on app startup
  • Next by Date: Re: Making 'return' Begin Editing, like Finder does
  • Previous by thread: NSOutlineView: How does Cocoa determine a click in a cell can start a drag operation?
  • Next by thread: Re: Making 'return' Begin Editing, like Finder does
  • Index(es):
    • Date
    • Thread