したがって、これらの問題の原因が何かはわかりませんが、これが私が行った回避策です。
コマンド (セレクター) を NSTextView に送信する NSTextField のサブクラスを作成しました。NSTextField には 1 つのサブビューがあり、そのサブビューには、実際には 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];
}
}
それを初期化するとき(このサブビュー検索よりも良い方法を誰かが知っている場合は教えてください)、取得するはずだったコマンドを送信します:
-(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];
}
最も洗練されたソリューションではないかもしれませんが、うまくいきます (そもそも何が問題だったのかを理解するまでは)。