Instance Method

trackMouse:inRect:ofView:untilMouseUp:

Initiates the mouse tracking behavior in a cell.

Declaration

- (BOOL)trackMouse:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView untilMouseUp:(BOOL)flag;

Parameters

theEvent

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.

untilMouseUp

If YES, mouse tracking continues until the user releases the mouse button. If NO, 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

YES if the mouse tracking conditions are met, otherwise NO.

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 YES, this method returns YES if the mouse button goes up while the cursor is anywhere; NO, otherwise. If untilMouseUp is set to NO, this method returns YES if the mouse button goes up while the cursor is within cellFrame; NO, otherwise.

This method first invokes startTrackingAt:inView:. If that method returns YES, then as mouse-dragged events are intercepted, continueTracking:at:inView: is invoked until either the method returns NO or the mouse is released. Finally, stopTracking:at:inView:mouseIsUp: is invoked if the mouse is released. If untilMouseUp is YES, it’s invoked when the mouse button goes up while the cursor is anywhere. If untilMouseUp is NO, 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

- startTrackingAt:inView:

Begins tracking mouse events within the receiver.

- continueTracking:at:inView:

Returns a Boolean value that indicates whether mouse tracking should continue in the receiving cell.

- stopTracking:at:inView:mouseIsUp:

Stops tracking mouse events within the receiver.

mouseDownFlags

The modifier flags for the last (left) mouse-down event.

prefersTrackingUntilMouseUp

Returns a Boolean value that indicates whether tracking stops when the cursor leaves the cell.

- getPeriodicDelay:interval:

Returns the initial delay and repeat values for continuous sending of action messages to target objects.