По сути, я хочу «невидимый» NSView, охватывающий весь мой экран. Я добавлю к этому NSTrackingArea, чтобы получать глобальные события мыши, когда мой курсор перемещается по экрану.
-(void)setTrackingArea
{
view = [[NSView alloc] initWithFrame:[NSScreen currentScreenForPoint:[NSEvent mouseLocation]].frame];
NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[NSScreen currentScreenForPoint:[NSEvent mouseLocation]].frame options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways owner:view userInfo:nil];
[view addTrackingArea:area];
[area release];
//[[window contentView] addSubview:view];
//I don't want to add the view to a window, as all tutorials say.
}
- (void)mouseExited:(NSEvent *)theEvent
{
NSLog(@"Exit"); //Never firing
}
Возможно ли это? Использование NSViews и NSTracking Areas без окна?