アプリデリゲートでウィンドウ「helpWindow」を作成し、そのコンテンツビューをNSViewサブクラスに設定しました。私のサブクラスでは、drawRectを作成し、そのキーウィンドウを確認します。私が抱えている問題は、マウスイベントでは、マウスダウンイベントはコンテンツビューで正常に機能しますが、移動したマウスが機能せず、場所が表示されないことです。に何かを追加する必要がありmouseLocation
ますか?drawRectがマウス移動イベントを隠蔽しているように感じます。ありがとう!
//私のappDelegate.mで
controlFilterBox = [[MoveFilter alloc] initWithFrame:helpWindow.frame];
[helpWindow setContentView:controlFilterBox];
[controlFilterBox release];
//NSViewサブクラスで.m
-(void)drawRect:(NSRect)dirtyRect
{
[[NSColor redColor] set];
NSRectFill(dirtyRect);
[[self window] makeKeyWindow];
}
-(void)mouseDown:(NSEvent *)theEvent
{
NSPoint eventLocation = [theEvent locationInWindow];
NSPoint location = [self convertPoint:eventLocation fromView:nil];
NSLog(@"exit %f %f", location.x, location.y);
}
-(void)mouseMoved:(NSEvent *)theEvent
{
NSPoint mouseLoc = [NSEvent mouseLocation];
NSLog(@"mouseMoved: %f %f", mouseLoc.x, mouseLoc.y);
}