So, I do not know what is the cause of these problems, but this is the roundabout solution I made.
I created a subclass of NSTextField that sends commands (selectors) to its NSTextView. NSTextField has one subview and that subview has yet another subview that is actually the NSTextView:
NSTextView* textView = nil;
NSArray* subs = [self subviews];
if( subs && [subs count] > 0 ){
NSView* firstView = [subs objectAtIndex:0];
NSArray* firstSubs = [firstView subviews];
if (firstSubs && [firstSubs count] > 0) {
textView = [firstSubs objectAtIndex:0];
}
}
When I initialise that one (if anyone knows a better way than this subview search, please tell), I send it the commands that it was supposed to get:
-(void)keyUp:(NSEvent *)theEvent{
BOOL isShift = (theEvent.modifierFlags & NSShiftKeyMask) > 0;
BOOL isCommand = (theEvent.modifierFlags & NSCommandKeyMask ) > 0;
switch (theEvent.keyCode) {
case 7: if( isCommand && !isShift ) [self notifyTextView:@selector(cut:)]; break;
case 8: if( isCommand && !isShift ) [self notifyTextView:@selector(copy:)]; break;
case 9: if( isCommand && !isShift ) [self notifyTextView:@selector(paste:)]; break;
case 123: [self notifyTextView:isShift ? @selector(moveLeftAndModifySelection:) : @selector(moveLeft:)];break;
case 124: [self notifyTextView:isShift ? @selector(moveRightAndModifySelection:) :@selector(moveRight:)];break;
case 117: [self notifyTextView:@selector(deleteForward:)];break;
default: break;
}
[super keyUp:theEvent];
}
Might not be the most elegant solution, but it works (until I figure out what went wrong in the first place).