Next Page > Hide TOC

Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

NSTextAttachment

Inherits from
Implements
Package
com.apple.cocoa.application
Companion guides

Overview

NSTextAttachment objects are used by the NSAttributedString class as the values for attachment attributes (stored in the attributed string under the key named AttachmentAttributeName). The objects you create with this class are referred to as text attachment objects, or when no confusion will result, as text attachments or merely attachments. See the NSAttributedString and NSTextView class specifications for general information on text attachments.

A text attachment object contains an NSFileWrapper, which in turn holds the contents of the attached file. It also uses a cell object conforming to the NSCellForTextAttachment interface to draw and handle mouse events. Most of the behavior of a text attachment is relegated to the file wrapper and the attachment cell. See the corresponding class and interface specifications for more information.

Tasks

Constructors

Setting the File Wrapper

Setting the Attachment Cell

Constructors

NSTextAttachment

Creates an empty NSTextAttachment.

public NSTextAttachment()

Creates an NSTextAttachment to contain aWrapper and use an NSTextAttachmentCell as its attachment cell.

public NSTextAttachment(NSFileWrapper aWrapper)

Discussion

If aWrapper contains an image file that the receiver can interpret as an NSImage object, sets the attachment cell’s image to the NSImage rather than to the icon of aWrapper.

See Also

Instance Methods

attachmentCell

Returns the object used to draw the icon for the receiver and to handle mouse events.

public NSCellForTextAttachment attachmentCell()

Discussion

An NSTextAttachment by default uses an NSTextAttachmentCell that displays the attached file’s icon, or its contents if the file contains an image.

See Also

fileWrapper

Returns the receiver’s file wrapper, which holds the contents of the attached file.

public NSFileWrapper fileWrapper()

See Also

setAttachmentCell

Sets the object used to draw the icon for the receiver and to handle mouse events to aCell.

public void setAttachmentCell(NSCellForTextAttachment aCell)

See Also

setFileWrapper

Sets the receiver’s file wrapper, which holds the contents of the attached file, to aWrapper.

public void setFileWrapper(NSFileWrapper aWrapper)

See Also

Constants

The following constant is provided by NSTextAttachment:

Constant

Description

AttachmentCharacter

Denotes attachments.



Next Page > Hide TOC


© 1997, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-01)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.