Adopted by: NSTextAttachmentCell
Declared in:
- AppKit/NSTextAttachment.h
The NSTextAttachmentCell protocol declares the interface for objects that draw text attachment icons and handle mouse events on their icons. With the exceptions of cellBaselineOffset, setAttachment: and attachment, all of these methods are implemented by the NSCell class and described in that class specification.
See the NSAttributedString and NSTextView class specifications for general information on text attachments.
- Drawing
- - drawWithFrame:inView:characterIndex:
- - drawWithFrame:inView:characterIndex:
- - highlight:withFrame:inView:
- Cell size and position
- - cellSize
- - cellBaselineOffset
- - cellFrameForTextContainer:proposedLineFragment:glyphPosition:characterIndex:
- Event handling
- - wantsToTrackMouse
- - trackMouse:inRect:ofView:untilMouseUp:
- - trackMouse:inRect:ofView:atCharacterIndex:untilMouseUp:
- Setting the attachment
- - setAttachment:
- - attachment
- (NSTextAttachment *)attachment
See Also: - setAttachment:
- (NSPoint)cellBaselineOffset
See Also: - icon (NSFileWrapper)
- (NSRect)cellFrameForTextContainer:(NSTextContainer
*)textContainer
proposedLineFragment:(NSRect)lineFrag
glyphPosition:(NSPoint)position
characterIndex:(unsigned)charIndex
- (NSSize)cellSize
See Also: - icon (NSFileWrapper), - fileWrapper (NSTextAttachment)
- (void)drawWithFrame:(NSRect)cellFrame
inView:(NSView *)aView
See Also: - drawWithFrameInViewdrawWithFrame:inView: (NSCell), - lockFocus (NSView)
- (void)drawWithFrame:(NSRect)cellFrame
inView:(NSView *)controlView
characterIndex:(unsigned)charIndex
- (void)highlight:(BOOL)flag
withFrame:(NSRect)cellFrame
inView:(NSView *)aView
See Also: - highlightWithFrameInViewhighlight:withFrame:inView: (NSCell), - lockFocus (NSView)
- (void)setAttachment:(NSTextAttachment
*)anAttachment
See Also: - attachment, - setAttachmentCell: (NSTextAttachment)
- (BOOL)trackMouse:(NSEvent
*)theEvent
inRect:(NSRect)cellFrame
ofView:(NSView *)aTextView
untilMouseUp:(BOOL)flag
NSTextAttachmentCell's 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 sends the delegate a textViewDoubleClickedCelltextView:doubleClickedOnCell:inRect: message and returns YES. Otherwise, depending on whether the user clicks or drags the cell, it sends the delegate a textViewClickedCelltextView:clickedOnCell:inRect: or a textViewDraggedCelltextView:draggedCell:inRect:event: message and returns YES. NSTextAttachmentCell's 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: - wantsToTrackMouse, - trackMouse:inRect:ofView:untilMouseUp: (NSCell), - lockFocus (NSView)
- (BOOL)trackMouse:(NSEvent
*)theEvent
inRect:(NSRect)cellFrame
ofView:(NSView *)controlView
atCharacterIndex:(unsigned)charIndex
untilMouseUp:(BOOL)flag
- (BOOL)wantsToTrackMouse
For an attachment in an attributed string, if the attachment cell returns NO its attachment character should be selected rather than the cell being asked to track the mouse. This results in the attachment icon behaving as any regular glyph in text.