-1
有没有办法检查鼠标是否在视图中?创建视图时不调用NSView - mouseEntered
有没有办法检查鼠标是否在视图中?创建视图时不调用NSView - mouseEntered
你的问题有点不清楚,但我想你想在你的自定义视图变得可见时检测鼠标的位置,如果鼠标位置在视图的边界内,则更新它。
如果是这样,你需要做的是这样的:
- (void)viewDidMoveToWindow
{
if(![self window])
return;
NSPoint mouseLocation = [[self window] mouseLocationOutsideOfEventStream];
if(NSPointInRect(mouseLocation, [self frame]))
{
NSLog(@"mouse is over the view");
}
else
{
NSLog(@"mouse is not over the view");
}
}