trackMouse(with:in:of:untilMouseUp:)
Handles a mouse-down event on the cell’s image, and optionally waits until a mouse-up event
Declaration
@MainActor func trackMouse(with theEvent: NSEvent, in cellFrame: NSRect, of controlView: NSView?, untilMouseUp flag: Bool) -> BoolParameters
- theEvent:
The mouse-down event.
- cellFrame:
The region of an Nstextview in which to track further mouse events.
- controlView:
The view that received the event. Typically, this view is an Nstextview object and is focused.
- flag:
A Boolean value that indicates whether to track the mouse until a mouse-up event occurs. If this parameter is False, stop tracking when a mouse-dragged event occurs outside of
cellFrame.
Return Value
true if the cell successfully finished tracking the mouse, or false if tracking was unsuccessful.
Discussion
The NSTextAttachmentCell implementation of this method calls upon aTextView’s delegate to handle the event. If theEvent is a mouse-up event for a double click, the text attachment cell calls the textView(_:doubleClickedOn:in:at:) method of its delegate and returns true. Otherwise, depending on whether the user clicks or drags the cell, it sends the delegate a textView(_:clickedOn:in:at:): or a textView(_:draggedCell:in:event:at:) message and returns true. The NSTextAttachmentCell implementation returns false only if flag is false and the mouse is dragged outside of cellFrame. The delegate methods are invoked only if the delegate responds.