user1548418
user1548418

Reputation: 497

Cursor turns into resize mode when dragging mouse outside NSTrackingArea aligned with NSWindow borders

I have a subclassed NSView that is aligned to the edges of the content area of the window, i.e. the view takes the whole area of the window.

Inside that custom NSView I install an NSTrackingArea also aligned with the edges of the view, to track mouse move and enter/exit events.

When I click mouse inside the view and drag outside the window, once the mouse intersects a window border, the cursor turns into resize shape (as if I was hovering over a window border) and remains in that shape, no matter where I drag - inside or far outside the window - until I release the mouse button.

I observe this bug also in many apps, even in Apple's own apps. In Safari for example, if you click on a background of a page and drag outside the window, the cursor sticks in resize mode.

The option flags of the NSTrackingArea don't seem to affect the bug. The bug only doesn't manifest if I don't add an NSTrackingArea.

This is really annoying, is there a workaround?

Here is my code:

- (void)updateTrackingAreas {
    if (_trackingArea != nil) {
        [self removeTrackingArea:_trackingArea];
    }
    NSRect trackingFrame = [self bounds];
    _trackingArea = [[NSTrackingArea alloc]
                     initWithRect:trackingFrame
                     options:(NSTrackingAreaOptions)(NSTrackingMouseMoved | NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways)
                     owner:self
                     userInfo:nil];
    [self addTrackingArea:_trackingArea];
}

Upvotes: 0

Views: 164

Answers (0)

Related Questions