#import "MyTableView.h"

@implementation MyTableView

- (void)setEnterAction:(SEL)aSelector {
    _enterAction = aSelector;
}

- (SEL)enterAction {
    return _enterAction;
}

- (void)keyDown:(NSEvent *)event {
    unichar key = [[event charactersIgnoringModifiers] characterAtIndex:0];
    unsigned int flags = [event modifierFlags];
    if ((flags&0xffff0000) == 0 && (key == NSEnterCharacter || key == NSCarriageReturnCharacter ||
                       key == NSNewlineCharacter)) {
        if (_enterAction != nil) {
            [[self target] performSelectorOnMainThread:_enterAction withObject:self waitUntilDone:YES];
        }
    } else {
        [super keyDown:event];
    }
}

/*- (void)insertNewline:(id)sender {
    printf("insertNewline\n");
    if (_enterAction != nil) {
        [[self target] performSelectorOnMainThread:_enterAction withObject:self waitUntilDone:YES];
    }
}*/

@end
