Instance Method

trackMouse:inRect:ofView:atCharacterIndex:untilMouseUp:

Handles a mouse-down event on the image at the specified character position.

Required.

Declaration

- (BOOL)trackMouse:(NSEvent *)theEvent inRect:(NSRect)cellFrame ofView:(NSView *)controlView atCharacterIndex:(NSUInteger)charIndex untilMouseUp:(BOOL)flag;

Parameters

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.

charIndex

The position in the text at which the attachment appears.

flag

A Boolean value that indicates whether to track the mouse until a mouse-up event occurs. If this parameter is NO, stop tracking when a mouse-dragged event occurs outside of cellFrame.

Return Value

YES if the cell successfully finished tracking the mouse, or NO 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:doubleClickedOnCell:inRect:atIndex: method of its delegate and returns YES. Otherwise, depending on whether the user clicks or drags the cell, it sends the delegate a textView:clickedOnCell:inRect:atIndex:: or a textView:draggedCell:inRect:event:atIndex: message and returns YES. The NSTextAttachmentCell implementation returns NO only if flag is NO and the mouse is dragged outside of cellFrame. The delegate methods are invoked only if the delegate responds.

See Also

Responding to Mouse Events

- wantsToTrackMouse

Returns a Boolean value that indicates whether the attachment handles mouse events occurring over its image.

Required.

- wantsToTrackMouseForEvent:inRect:ofView:atCharacterIndex:

Allows an attachment to specify the events for which it tracks the mouse.

Required.

- trackMouse:inRect:ofView:untilMouseUp:

Handles a mouse-down event on the cell's image, and optionally waits until a mouse-up event

Required.