Protocol

NSTextAttachmentCellProtocol

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(), attachment, and attachment, all of these methods are implemented by the NSCell class and described in that class specification.

Overview

See the NSAttributedString and NSTextView class specifications for general information on text attachments.

Symbols

Drawing

func draw(withFrame: NSRect, in: NSView?)
Required.

Draws the receiver’s image within cellFrame in aView, which is the view currently focused.

func draw(withFrame: NSRect, in: NSView?, characterIndex: Int)
Required.

Draws the receiver’s image within cellFrame in aView, which is the view currently focused. charIndex is the index of the attachment character within the text.

func draw(withFrame: NSRect, in: NSView?, characterIndex: Int, layoutManager: NSLayoutManager)
Required.

Draws the receiver’s image within cellFrame in controlView, which is the view currently focused. charIndex is the index of the attachment character within the text. layoutManager is the layout manager for the text.

func highlight(Bool, withFrame: NSRect, in: NSView?)
Required.

Draws the receiver’s image—with highlighting if flag is true—within cellFrame in aView, which should be the focus view.

Cell size and position

func cellSize()
Required.

Returns the size of the attachment’s icon.

func cellBaselineOffset()
Required.

Returns the position where the attachment cell’s image should be drawn in text, relative to the current point established in the glyph layout.

func cellFrame(for: NSTextContainer, proposedLineFragment: NSRect, glyphPosition: NSPoint, characterIndex: Int)
Required.

Returns the frame of the cell as it would be drawn as the character at the given glyph position, and character index, charIndex, in textContainer.

Event handling

func wantsToTrackMouse()
Required.

Returns true if the receiver will handle a mouse event occurring over its image (to support dragging, for example), false otherwise.

func wantsToTrackMouse(for: NSEvent, in: NSRect, of: NSView?, atCharacterIndex: Int)
Required.

Allows an attachment to specify what events it would want to track the mouse for.

func trackMouse(with: NSEvent, in: NSRect, of: NSView?, untilMouseUp: Bool)
Required.

Handles a mouse-down event on the receiver’s image.

Setting the attachment

var attachment: NSTextAttachment?
Required.

Returns the text attachment object that owns the receiver.

Relationships

Inherits From