For cursor update events (with NSTrackingArea) how to know if it's coming or going?

I've added an NSTrackingArea to my NSView because I want a certain rectangular area to show a different cursor. As expected, my view gets a call to it's cursorUpdate:(NSEvent*) method, but how do I tell whether it's an "enter" or "leave".

- (void)cursorUpdate:(NSEvent *)event {    
    // Do I push or pop my custom NSCursor?
}

I notice the event.modifierFlags changes from 8 to 9. But I don't see any public enum constants to test that, so I don't know if I can depend on that. The public enum contains stuff like this, in the higher bits.

typedef NS_OPTIONS(NSUInteger, NSEventModifierFlags) {
    NSEventModifierFlagCapsLock           = 1 << 16,
    NSEventModifierFlagShift              = 1 << 17,
    ...

The tracking area setup code:

NSRect nsRect = ...
NSTrackingAreaOptions options = NSTrackingCursorUpdate | NSTrackingActiveInKeyWindow;
NSTrackingArea *trackingArea = [[NSTrackingArea alloc] initWithRect: nsRect options: options owner: owner userInfo: userInfo];
[myView addTrackingArea: trackingArea];

It's Swift, but immediate to convert to objC.

In this example I subclass NSTextField or NSButton

class TextFieldWithHelp: NSTextField { }

I override 2 func:

    override func mouseEntered(with theEvent: NSEvent) {
        
        super.mouseEntered(with: theEvent)
        myCursor!.set()     // Set cursor
    }
    
    
    override func mouseExited(with theEvent: NSEvent) {
        
        super.mouseExited(with: theEvent)
        arrowCursor!.set()       // restore the default arrow
    }

Then I use trackingArea, with mouseEnteredAndExited and cursorUpdate options (helperButton is of the subclass)

        if helperButtonTrackingArea == nil {
            helperButtonTrackingArea = NSTrackingArea(rect: helperButton.bounds, options: [NSTrackingArea.Options.mouseEnteredAndExited, NSTrackingArea.Options.cursorUpdate, NSTrackingArea.Options.activeInKeyWindow], owner: helperButton, userInfo: nil)
            helperButton.addTrackingArea(helperButtonTrackingArea!)
        }
For cursor update events (with NSTrackingArea) how to know if it's coming or going?
 
 
Q