FROM : Jerry Krinock
DATE : Mon Feb 04 19:33:37 2008
On 2008 Feb, 03, at 15:37, Ricky Sharp wrote:
> Well, you can always use NSCarriageReturnCharacter instead.
>
> Also, Finder handles the Enter key as well to start editing. For
> that, use NSEnterCharacter.
How foolish of me to have not suspected that the key codes for ASCII
control characters would "obviously" be found in NSText.h, while all
the other function key codes are in NSEvent.h :|
Another issue closed, thanks to Ricky Sharp.
Revised, tested code, responding to both 'return' and 'enter', is below.
- (void)keyDown:(NSEvent*)event {
NSString *s = [event charactersIgnoringModifiers] ;
unichar keyChar = 0 ;
BOOL didDo = NO ;
if ([s length] == 1) {
keyChar = [s characterAtIndex:0] ;
if ((keyChar == NSCarriageReturnCharacter) || (keyChar ==
NSEnterCharacter)) {
// 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] ;
}
}
DATE : Mon Feb 04 19:33:37 2008
On 2008 Feb, 03, at 15:37, Ricky Sharp wrote:
> Well, you can always use NSCarriageReturnCharacter instead.
>
> Also, Finder handles the Enter key as well to start editing. For
> that, use NSEnterCharacter.
How foolish of me to have not suspected that the key codes for ASCII
control characters would "obviously" be found in NSText.h, while all
the other function key codes are in NSEvent.h :|
Another issue closed, thanks to Ricky Sharp.
Revised, tested code, responding to both 'return' and 'enter', is below.
- (void)keyDown:(NSEvent*)event {
NSString *s = [event charactersIgnoringModifiers] ;
unichar keyChar = 0 ;
BOOL didDo = NO ;
if ([s length] == 1) {
keyChar = [s characterAtIndex:0] ;
if ((keyChar == NSCarriageReturnCharacter) || (keyChar ==
NSEnterCharacter)) {
// 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] ;
}
}
| Related mails | Author | Date |
|---|---|---|
| Jerry Krinock | Feb 4, 00:30 | |
| Ricky Sharp | Feb 4, 00:37 | |
| Jerry Krinock | Feb 4, 19:33 |






Cocoa mail archive

