I have an NSOutlineView
that I'd ike to have mouseEntered:
and mouseExited:
updates during drag and drop. So I've tried to add an NSTrackingArea
to it. Within my outline view sub-class I have:
let target = self.frame
let options = [NSTrackingAreaOptions.enabledDuringMouseDrag]
let area = NSTrackingArea(rect: target, options: options, owner: self, userInfo: nil)
self.addTrackingArea(area)
But I seem to get the runtime exception:
[General] trackingArea options 0x400 do not include a type
It must be something really obvious but all the Google results don't seem to indicate what I'm doing wrong. If I do:
var trackingID = self.addTrackingRect(target, owner: self, userData: nil, assumeInside: false)
then the mouse methods do fire but obviously only when the mouse button is released.
From the documentation:
NSTrackingAreaOptions
The data type defined for the constants specified in the options parameter of
init(rect:options:owner:userInfo:)
. These constants are described below; you can specify multiple constants by performing a bitwise-OR operation with them. In particular, you must supply one or more of the tracking-type constants (that is,mouseEnteredAndExited
,mouseMoved
, andcursorUpdate
) and one of the active constants (that is,activeWhenFirstResponder
,activeInKeyWindow
,activeInActiveApp
, andactiveAlways
). In addition, you may specify any of the behavior constants (that is,assumeInside
,inVisibleRect
, andenabledDuringMouseDrag
).
That means one or more of the type
constants and one of the active
constants are required.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With