0
NSViewの単純なサブクラスを作成しましたが、becomeFirstResponder
を呼び出しても効果がないようです - フレームワークは私のacceptsFirstResponder
メソッドを呼び出しません。カスタムNSViewを最初のレスポンダとして設定できません
私のビューでマウスをクリックすると、最初のレスポンダーとなり、keyDown
というイベントを受け取ることができます。ここで
は私のNSViewのサブクラスである:私は間違っ
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSRect frameRect = NSMakeRect(0,0,100,100);
MyView *myView = [[MyView alloc] initWithFrame:frameRect];
[_window.contentView addSubview:myView];
[myView becomeFirstResponder];
}
何をしています:
@interface MyView : NSView
@end
@implementation MyView
- (void) keyDown: (NSEvent*) with {
NSLog(@"keyDown");
}
- (BOOL)acceptsFirstResponder {
NSLog(@"acceptsFirstResponder");
return YES;
}
- (BOOL)canBecomeKeyView {
NSLog(@"canBecomeKeyView");
return YES;
}
@end
そして、ここでは、私は私のAppDelegate
でそれを設定してい方法ですか?
'becomeFirstResponder'のドキュメントをお読みですか? – Willeke