Contents

trackMouse(with:in:of:untilMouseUp:)

Initiates the mouse tracking behavior in a cell.

Declaration

func trackMouse(with event: NSEvent, in cellFrame: NSRect, of controlView: NSView, untilMouseUp flag: Bool) -> Bool

Parameters

  • event:

    The event that caused the mouse tracking to occur.

  • cellFrame:

    The receiver’s frame rectangle.

  • controlView:

    The view containing the receiver. This is usually an NSControl object.

  • flag:

    If True, mouse tracking continues until the user releases the mouse button. If False, tracking continues until the cursor leaves the tracking rectangle, specified by the cellFrame parameter, regardless of the mouse button state. See the discussion for more information.

Return Value

true if the mouse tracking conditions are met, otherwise false.

Discussion

This method is generally not overridden because the default implementation invokes other NSCell methods that can be overridden to handle specific events in a dragging session. This method’s return value depends on the untilMouseUp flag. If untilMouseUp is set to true, this method returns true if the mouse button goes up while the cursor is anywhere; false, otherwise. If untilMouseUp is set to false, this method returns true if the mouse button goes up while the cursor is within cellFrame; false, otherwise.

This method first invokes startTracking(at:in:). If that method returns true, then as mouse-dragged events are intercepted, continueTracking(last:current:in:) is invoked until either the method returns false or the mouse is released. Finally, stopTracking(last:current:in:mouseIsUp:) is invoked if the mouse is released. If untilMouseUp is true, it’s invoked when the mouse button goes up while the cursor is anywhere. If untilMouseUp is false, it’s invoked when the mouse button goes up while the cursor is within cellFrame. You usually override one or more of these methods to respond to specific mouse events.

See Also

Tracking the Mouse