Developer Documentation
PATH  Mac OS X Documentation > Application Kit Reference: Java

Table of Contents

NSText


Inherits from:
NSView : NSResponder : NSObject
Implements:
NSChangeSpelling
NSIgnoreMisspelledWords
Package:
com.apple.yellow.application

Class at a Glance


NSText declares the most general programmatic interface for objects that manage text. You usually use instances of its subclass, NSTextView.

Principal Attributes


Commonly Used Methods



readRTFDFromFile Reads an .rtf or .rtfd file.
writeRTFDToFile Writes the receiver's text to a file.
string Returns the receiver's text, without attributes.
RTFFromRange Returns the receiver's text with attributes.
RTFDFromRange Returns the receiver's text with attributes and attachments.


Class Description


The NSText class declares the most general programmatic interface to objects that manage text. Cocoa offers a subclass of NSText, NSTextView, that extends the interface declared by NSText and provides much more sophisticated functionality than that declared in NSText.

NSText's constructor creates an instance of a concrete subclass, such as NSTextView. Instances of any of these classes are generically called text objects.

Text objects are used by the Application Kit wherever text appears in interface objects: A text object draws the title of a window, the commands in a menu, the title of a button, and the items in a browser. Your application can also create text objects for its own purposes.

The text classes are unlike most other classes in the Application Kit in the richness and complexity of their interface. One of their design goals is to provide a comprehensive set of text-handling features so that you'll rarely need to create a subclass. Among other things, a text object can:

Graphical user-interface building tools (such as Interface Builder) may give you access to text objects in several different configurations, such as those found in the NSTextField, NSForm, and NSScrollView objects. These classes configure a text object for their own specific purposes. Additionally, all NSTextFields, NSForms, NSButtons within the same window-in short, all objects that access a text object through associated cells-share the same text object, reducing the memory demands of an application. Thus, it's generally best to use one of these classes whenever it meets your needs, rather than create text objects yourself. If one of these classes doesn't provide enough flexibility for your purposes, you can create text objects programmatically.

Text objects typically work closely with various other objects. Some of these-such as the delegate or an embedded graphic object-require a degree of programming on your part. Others-such as the Font Panel, spell checker, or ruler-take no effort other than deciding whether the service should be enabled or disabled. Several of the following sections discuss these interrelationships.


Plain and Rich Text Objects


Text objects are differentiated into two groups: those that allow only one set of text attributes for all of their text, and those that allow multiple fonts, sizes, indents, and other attributes for different sets of characters and paragraphs. Text objects in the former group are called plain text objects, while those in the latter are called rich text objects. You can control whether a text object is plain or rich using the setRichText method. Rich text objects are also capable of allowing the user to drag images and files into them. This behavior is controlled by the setImportsGraphics method.

A rich NSText object can use RTF (Rich Text Format) as an interchange format. Not all RTF control words are supported: On input, an NSText object ignores any control word it doesn't recognize; some of those it can read and interpret it doesn't write out. The table below lists the RTF control words that any text object recognizes. Subclasses may recognize more.


Control Word Read Write
\ansi yes yes
\b yes yes
\cb yes yes
\cf yes yes
\colortbl yes yes
\dnn yes yes
\fin yes yes
\fn yes yes
\fonttbl yes yes
\fsn yes yes
\i yes yes
\lin yes yes
\margrn yes yes
\paperwn yes yes
\mac yes no
\margln yes yes
\par yes yes
\pard yes no
\pca yes no
\qc yes yes
\ql yes yes
\qr yes yes
\sn yes no
\tab yes yes
\upn yes yes


Notifying a Text Object's Delegate


Many of an NSText object's actions can be controlled through an associated object, the NSText object's delegate. The delegate can be any object you choose, and one delegate can control multiple NSText objects. If it implements any of the following methods, the delegate receives the corresponding message at the appropriate time:

Of special note are the two "textShould..." methods. These methods are requests for permission. Any time a text object begins an operation that would change its text or attributes, it uses textShouldBeginEditing to request approval for the change. The delegate can return true to permit the change, or false to forbid it. Similarly, textShouldEndEditing enables the delegate to prevent a text object from ending editing, such as when it contains an invalid value.


Adding Graphics and Other Attachments to the Text


A rich text object may allow graphics or other file attachments to be embedded in the text. Each graphic is treated as a single (possibly large) "character": The text's line height and character placement are adjusted to accommodate the graphic. Graphics are embedded in the text in either of two ways: programmatically or directly through user actions. In the programmatic approach, graphic objects can be added using replaceRange:WithRTFD:, or through a more specific method defined by a subclass.

An alternate means of adding an image or other attachment to the text is for the user to drag an image or other file directly into the text object. The text object automatically creates an attachment object to manage the display of the image. This feature requires a rich text object that has been configured to receive dragged images using the setImportsGraphics method.

Images that have been imported can be written as part of an RTFD document. RTFD documents use a file package, or directory, to store the components of the document (the "D" stands for "directory"). The file package has the name of the document plus an .rtfd extension. The file package always contains a file called TXT.rtf for the text of the document, and one or more TIFF or EPS files for the images, plus the files for other attachments. A text object can transfer information in an RTFD document to a file and read it from a file using the writeRTFDToFile and readRTFDFromFile methods.


Working with the Font Panel


Text objects are designed to work with the Application Kit's font conversion system, defined by the NSFontPanel and NSFontManager classes. By default, a text object keeps the Font Panel updated with the first font in its selection, or of its typing attributes (defined below). It also changes the font in response to messages from the Font Panel and Font menu. Such changes apply to the selected text or typing attributes for a rich text object, or to all the text in a plain text object. You can turn this behavior off using the setUsesFontPanel method. Doing so is recommended for a text object that serves as a field editor, for example.


Working with Rulers and Paragraph Styles


Text objects also provide for a ruler, by which the user can edit paragraph attributes such as indents and tabs. NSTextView works with the NSRulerView class and uses the NSTextStorage and NSParagraphStyle classes to handle paragraph attributes. To show or hide a text object's ruler, use the toggleRuler action method. Similar to the Font Panel, NSTextView can be set not to use a ruler with the setUsesRuler method.




Constants


These constants specify text alignment:


Constants Description
LeftTextAlignment Description forthcoming.
RightTextAlignment Description forthcoming.
CenterTextAlignment Description forthcoming.
JustifiedTextAlignment Description forthcoming.
NaturalTextAlignment Use the natural alignment of the text's script

These constants specify the movement between fields. They are used by TextDidEndEditingNotification.


Constants Description
IllegalTextMovement Description forthcoming.
ReturnTextMovement Description forthcoming.
TabTextMovement Description forthcoming.
BacktabTextMovement Description forthcoming.
LeftTextMovement Description forthcoming.
RightTextMovement Description forthcoming.
UpTextMovement Description forthcoming.
DownTextMovement Description forthcoming.

These constants specify several commonly-used Unicode characters.


Constants Description
ParagraphSeparatorCharacter Description forthcoming.
LineSeparatorCharacter Description forthcoming.
TabCharacter Description forthcoming.
FormFeedCharacter Description forthcoming.
NewlineCharacter Description forthcoming.
CarriageReturnCharacter Description forthcoming.
EnterCharacter Description forthcoming.
BackspaceCharacter Description forthcoming.
DeleteCharacter Description forthcoming.



Interfaces Implemented


NSChangeSpelling
- changeSpelling:
NSIgnoreMisspelledWords
- ignoreSpelling:


Method Types


Constructors
NSText
Getting the characters
string
Setting graphic attributes
setBackgroundColor
backgroundColor
setDrawsBackground
drawsBackground
Setting behavioral attributes
setEditable
isEditable
setSelectable
isSelectable
setFieldEditor
isFieldEditor
setRichText
isRichText
setImportsGraphics
importsGraphics
Using the Font Panel and menu
setUsesFontPanel
usesFontPanel
Using the ruler
toggleRuler
isRulerVisible
Changing the selection
setSelectedRange
selectedRange
Replacing text
replaceCharactersInRangeWithRTF
replaceCharactersInRangeWithRTFD
replaceCharactersInRange
setString
Action methods for editing
selectAll
copy
cut
paste
copyFont
pasteFont
copyRuler
pasteRuler
delete
Changing the font
changeFont
setFont
setFontInRange
font
Setting text alignment
setAlignment
alignCenter
alignLeft
alignRight
alignment
Setting text color
setTextColor
setTextColorInRange
textColor
Setting super- and subscripting
superscript
subscript
unscript
Underlining text
underline
Reading and writing RTF
readRTFDFromFile
writeRTFDToFile
RTFDFromRange
RTFFromRange
Checking spelling
checkSpelling
changeSpelling
ignoreSpelling
showGuessPanel
Constraining size
setMaxSize
maxSize
setMinSize
minSize
setVerticallyResizable
isVerticallyResizable
setHorizontallyResizable
isHorizontallyResizable
sizeToFit
Scrolling
scrollRangeToVisible
Setting the delegate
setDelegate
delegate


Constructors



NSText

public NSText()

Description forthcoming.

public NSText(NSRect frameRect)

Creates a text object with frameRect as its frame rectangle. This method actually substitutes an instance of a concrete subclass of NSText, such as NSTextView, and configures that instance to archive itself.


Instance Methods



alignCenter

public void alignCenter(Object sender)

This action method applies center alignment to selected paragraphs (or all text if the receiver is a plain text object).

See Also: alignLeft, alignRight, alignment, setAlignment



alignLeft

public void alignLeft(Object sender)

This action method applies left alignment to selected paragraphs (or all text if the receiver is a plain text object).

See Also: alignCenter, alignRight, alignment, setAlignment



alignRight

public void alignRight(Object sender)

This action method applies right alignment to selected paragraphs (or all text if the receiver is a plain text object).

See Also: alignLeft, alignCenter, alignment, setAlignment



alignment

public int alignment()

Returns the alignment of the first selected paragraph, or of all text for a plain text object. This value is one of the alignments described in "Constants" .

Text using NaturalTextAlignment is actually displayed using one of the other alignments, depending on the natural alignment of the text's script.



backgroundColor

public NSColor backgroundColor()

Returns the receiver's background color.

See Also: drawsBackground, setBackgroundColor



changeSpelling

public void changeSpelling(Object sender)

Description forthcoming.

changeFont

public void changeFont(Object sender)

This action method changes the font of the selection for a rich text object, or of all text for a plain text object. If the receiver doesn't use the Font Panel, this method does nothing.

This method changes the font by sending a convertFont message to the shared NSFontManager, and applying each NSFont returned to the appropriate text. See the NSFontManager class specification for more information on font conversion.

See Also: usesFontPanel



checkSpelling

public void checkSpelling(Object sender)

This action method searches for a misspelled word in the receiver's text. The search starts at the end of the selection and continues until it reaches a word suspected of being misspelled or the end of the text. If a word isn't recognized by the spelling server, a showGuessPanel message then opens the Guess panel and allows the user to make a correction or add the word to the local dictionary.

See Also: showGuessPanel



copy

public void copy(Object sender)

This action method copies the selected text onto the general pasteboard, in as many formats as the receiver supports. A plain text object uses NSPasteboard.StringPboardType for plain text, and a rich text object also uses NSPasteboard.RTFPboardType.

See Also: copyFont, copyRuler, cut, paste



copyFont

public void copyFont(Object sender)

This action method copies the font information for the first character of the selection (or for the insertion point) onto the font pasteboard, as NSPasteboard.FontPboardType.

See Also: copy, copyRuler, cut, paste



copyRuler

public void copyRuler(Object sender)

This action method copies the paragraph style information for first selected paragraph onto the ruler pasteboard, as NSPasteboard.RulerPboardType, and expands the selection to paragraph boundaries.

See Also: copy, copyFont, cut, paste



cut

public void cut(Object sender)

This action method deletes the selected text and places it onto the general pasteboard, in as many formats as the receiver supports. A plain text object uses NSPasteboard.StringPboardType for plain text, and a rich text object also uses NSPasteboard.RTFPboardType.

See Also: delete, copy, copyFont, copyRuler, paste



delegate

public Object delegate()

Returns the receiver's delegate, or null if it has none.

See Also: setDelegate



delete

public void delete(Object sender)

This action method deletes the selected text.

See Also: cut



drawsBackground

public boolean drawsBackground()

Returns true if the receiver draws its background, false if it doesn't.

See Also: backgroundColor, setDrawsBackground



font

public NSFont font()

Returns the font of the first character in the receiver's text, or of the insertion point if there's no text.

See Also: setFont, setFontInRange



ignoreSpelling

public void ignoreSpelling(Object sender)

Description forthcoming.

importsGraphics

public boolean importsGraphics()

Returns true if the receiver allows the user to import files by dragging, false if it doesn't. A text object that accepts dragged files is also a rich text object.

See Also: isRichText, setImportsGraphics



isEditable

public boolean isEditable()

Returns true if the receiver allows the user to edit text, false if it doesn't. You can change the receiver's text programmatically regardless of this setting.

If the receiver is editable, it's also selectable.

See Also: isSelectable, setEditable



isFieldEditor

public boolean isFieldEditor()

Returns true if the receiver interprets Tab, Shift-Tab, and Return (Enter) as cues to end editing, and possibly to change the first responder; false if it accepts them as text input. See the NSWindow class specification for more information on field editors. By default, NSText objects don't behave as field editors.

See Also: setFieldEditor



isHorizontallyResizable

public boolean isHorizontallyResizable()

Returns true if the receiver automatically changes its width to accommodate the width of its text, false if it doesn't.

See Also: isVerticallyResizable, setHorizontallyResizable



isRichText

public boolean isRichText()

Returns true if the receiver allows the user to apply attributes to specific ranges of the text, false if it doesn't.

See Also: importsGraphics, setRichText



isRulerVisible

public boolean isRulerVisible()

Returns true if the receiver's enclosing scroll view shows its ruler, false otherwise.

See Also: toggleRuler



isSelectable

public boolean isSelectable()

Returns true if the receiver allows the user to select text, false if it doesn't.

See Also: isEditable, setSelectable



isVerticallyResizable

public boolean isVerticallyResizable()

Returns true if the receiver automatically changes its height to accommodate the height of its text, false if it doesn't.

See Also: isHorizontallyResizable, setVerticallyResizable



maxSize

public NSSize maxSize()

Returns the receiver's maximum size.

See Also: minSize, setMaxSize



minSize

public NSSize minSize()

Returns the receiver's minimum size.

See Also: maxSize, setMinSize



paste

public void paste(Object sender)

This action method pastes text from the general pasteboard at the insertion point or over the selection.

See Also: copy, cut, pasteFont, pasteRuler



pasteFont

public void pasteFont(Object sender)

This action method pastes font information from the font pasteboard onto the selected text or insertion point of a rich text object, or over all text of a plain text object.

See Also: copyFont, pasteRuler



pasteRuler

public void pasteRuler(Object sender)

This action method pastes paragraph style information from the ruler pasteboard onto the selected paragraphs of a rich text object. It doesn't apply to a plain text object.

See Also: copyFont, pasteRuler



readRTFDFromFile

public boolean readRTFDFromFile(String path)

Attempts to read the RTFD file at path, returning true if successful and false if not. path should be the path for an .rtf file or an .rtfd file wrapper, not for the RTF file within an .rtfd file wrapper

See Also: writeRTFDToFile



replaceCharactersInRange

public void replaceCharactersInRange( NSRange aRange, String aString)

Replaces the characters in aRange with aString. For a rich text object, the text of aString is assigned the formatting attributes of the first character of the text it replaces, or of the character immediately before aRange if the range's length is zero. If the range's location is zero, the formatting attributes of the first character in the receiver are used.

See Also: replaceCharactersInRangeWithRTF, replaceCharactersInRangeWithRTFD



replaceCharactersInRangeWithRTF

public void replaceCharactersInRangeWithRTF( NSRange aRange, NSData rtfData)

Replaces the characters in aRange with RTF text interpreted from rtfData. This method applies only to rich text objects.

See Also: replaceCharactersInRangeWithRTFD, replaceCharactersInRange



replaceCharactersInRangeWithRTFD

public void replaceCharactersInRangeWithRTFD( NSRange aRange, NSData rtfdData)

Replaces the characters in aRange with RTFD text interpreted from rtfdData. This method applies only to rich text objects.

See Also: replaceCharactersInRangeWithRTF, replaceCharactersInRange



RTFDFromRange

public NSData RTFDFromRange(NSRange aRange)

Returns an NSData object that contains an RTFD stream corresponding to the characters and attributes within aRange. Throws a RangeException if any part of aRange lies beyond the end of the receiver's characters.

When writing data to the pasteboard, you can use the NSData object as the first argument to NSPasteboard's setDataForType method, with a second argument of NSPasteboard.RTFDPboardType.

See Also: RTFFromRange



RTFFromRange

- (NSData *)RTFFromRange:(NSRange)aRange

Returns an NSData object that contains an RTF stream corresponding to the characters and attributes within aRange, omitting any attachment characters and attributes. Throws a RangeException if any part of aRange lies beyond the end of the receiver's characters.

When writing data to the pasteboard, you can use the NSData object as the first argument to NSPasteboard's setDataForType method, with a second argument of NSPasteboard.RTFPboardType.

See Also: RTFDFromRange



scrollRangeToVisible

public void scrollRangeToVisible(NSRange aRange)

Scrolls the receiver in its enclosing scroll view so the first characters of aRange are visible.

selectAll

public void selectAll(Object sender)

This action method selects all of the receiver's text.

selectedRange

public NSRange selectedRange()

Returns the range of selected characters.

See Also: setSelectedRange



setAlignment

public void setAlignment(int mode)

Sets the alignment of all the receiver's text to mode. mode may be one of the alignments described in "Constants" .

Text using NaturalTextAlignment is actually displayed using one of the other alignments, depending on the natural alignment of the text's script.

See Also: alignment, alignLeft, alignCenter, alignRight



setBackgroundColor

public void setBackgroundColor(NSColor aColor)

Sets the receiver's background color to aColor.

See Also: setDrawsBackground, backgroundColor



setDelegate

public void setDelegate(Object anObject)

Sets the receiver's delegate to anObject, without retaining it.

See Also: delegate



setDrawsBackground

public void setDrawsBackground(boolean flag)

Controls whether the receiver draws its background. If flag is true, the receiver fills its background with the background color; if flag is false, it doesn't.

See Also: setBackgroundColor, drawsBackground



setEditable

public void setEditable(boolean flag)

Controls whether the receiver allows the user to edit its text. If flag is true, the receiver allows the user to edit text and attributes; if flag is false, it doesn't. You can change the receiver's text programmatically regardless of this setting. If the receiver is made editable, it's also made selectable. NSText objects are by default editable.

See Also: setSelectable, isEditable



setFieldEditor

public void setFieldEditor(boolean flag)

Controls whether the receiver interprets Tab, Shift-Tab, and Return (Enter) as cues to end editing, and possibly to change the first responder. If flag is true, it does; if flag is false, it doesn't, instead accepting these characters as text input. See the NSWindow class specification for more information on field editors. By default, NSText objects don't behave as field editors.

See Also: isFieldEditor



setFont

public void setFont(NSFont aFont)

Sets the font of all the receiver's text to aFont.

See Also: setFontInRange, font



setFontInRange

public void setFontInRange( NSFont aFont, NSRange aRange)

Sets the font of characters within aRange to aFont. This method applies only to a rich text object.

See Also: setFont, font



setHorizontallyResizable

public void setHorizontallyResizable(boolean flag)

Controls whether the receiver changes its width to fit the width of its text. If flag is true it does; if flag is false it doesn't.

See Also: setVerticallyResizable, isHorizontallyResizable



setImportsGraphics

public void setImportsGraphics(boolean flag)

Controls whether the receiver allows the user to import files by dragging. If flag is true, it does; if flag is false, it doesn't. If the receiver is set to accept dragged files, it's also made a rich text object. Subclasses may or may not accept dragged files by default.

See Also: setRichText, importsGraphics



setMaxSize

public void setMaxSize(NSSize aSize)

Sets the receiver's maximum size to aSize.

See Also: setMinSize, maxSize



setMinSize

public void setMinSize(NSSize aSize)

Sets the receiver's minimum size to aSize.

See Also: setMaxSize, minSize



setRichText

public void setRichText(boolean flag)

Controls whether the receiver allows the user to apply attributes to specific ranges of the text. If flag is true it does; if flag is false it doesn't. If flag is false, the receiver is also set not to accept dragged files. Subclasses may or may not let the user apply multiple attributes to the text and accept drag files by default.

See Also: isRichText, setImportsGraphics



setSelectable

public void setSelectable(boolean flag)

Controls whether the receiver allows the user to select its text. If flag is true, the receiver allows the user to select text; if flag is false, it doesn't. You can set selections programmatically regardless of this setting. If the receiver is made not selectable, it's also made not editable. NSText objects are by default editable and selectable.

See Also: setEditable, isSelectable



setSelectedRange

public void setSelectedRange(NSRange aRange)

Selects the receiver's characters within aRange.

See Also: selectedRange



setString

public void setString(String aString)

Replaces the receiver's entire text with aString, applying the formatting attributes of the old first character to its new contents.

setTextColor

public void setTextColor(NSColor aColor)

Sets the text color of all characters in the receiver to aColor. Removes the text color attribute if aColor is null.

See Also: setTextColorInRange, textColor



setTextColorInRange

public void setTextColorInRange( NSColor aColor, NSRange aRange)

Sets the text color of characters within aRange to aColor. Removes the text color attribute if aColor is null. This method applies only to rich text objects.

See Also: setTextColor, textColor



setUsesFontPanel

public void setUsesFontPanel(boolean flag)

Controls whether the receiver uses the Font Panel and Font menu. If flag is true, the receiver responds to messages from the Font Panel and from the Font menu, and updates the Font Panel with the selection font whenever it changes. If flag is false the receiver doesn't do any of this. By default, an NSText object uses the Font Panel and menu.

See Also: usesFontPanel



setVerticallyResizable

public void setVerticallyResizable(boolean flag)

Controls whether the receiver changes its height to fit the height of its text. If flag is true it does; if flag is false it doesn't.

See Also: setHorizontallyResizable, isVerticallyResizable



showGuessPanel

public void showGuessPanel(Object sender)

This action method opens the Spelling panel, allowing the user to make a correction during spell checking.

See Also: checkSpelling



sizeToFit

public void sizeToFit()

Resizes the receiver to fit its text.

See Also: isHorizontallyResizable, isVerticallyResizable



string

public String string()

Returns the characters of the receiver's text. For performance reasons, this method returns the current backing store of the text object. If you want to maintain a snapshot of this as you manipulate the text storage, you should make a copy of the appropriate substring.

See Also: setString



subscript

public void subscript(Object sender)

This action method applies a subscript attribute to selected text (or all text if the receiver is a plain text object), lowering its baseline offset by a predefined amount.

See Also: subscript, unscript, lowerBaseline (NSTextView)



superscript

public void superscript(Object sender)

This action method applies a superscript attribute to selected text (or all text if the receiver is a plain text object), raising its baseline offset by a predefined amount.

See Also: subscript, unscript, raiseBaseline (NSTextView)



textColor

public NSColor textColor()

Returns the color of the receiver's first character, or for the insertion point if there's no text.

See Also: setTextColor, setTextColorInRange



toggleRuler

public void toggleRuler(Object sender)

This action method shows or hides the ruler, if the receiver is enclosed in a scroll view.

underline

public void underline(Object sender)

This action method underlines selected text for a rich text object, or all text for a plain text object.

unscript

public void unscript(Object sender)

This action method removes any superscripting or subscripting from selected text (or all text if the receiver is a plain text object).

See Also: subscript, superscript, raiseBaseline (NSTextView), lowerBaseline (NSTextView)



usesFontPanel

public boolean usesFontPanel()

Returns true if the receiver uses the Font Panel, false otherwise.

See Also: setUsesFontPanel



writeRTFDToFile

public boolean writeRTFDToFile( String path, boolean atomicFlag)

Writes the receiver's text as RTF with attachments to a file or directory at path. Returns true on success and false on failure. If atomicFlag is true, attempts to write the file safely so that an existing file at path is not overwritten, nor does a new file at path actually get created, unless the write is successful.

See Also: RTFFromRange, RTFDFromRange, readRTFDFromFile




Methods Implemented By the Delegate


textDidBeginEditing

public abstract void textDidBeginEditing(NSNotification aNotification)

Informs the delegate that the text object has begun editing (that the user has begun changing it). The name of aNotification is TextViewDidBeingEditingNotification.

textDidChange

public abstract void textDidChange(NSNotification aNotification)

Informs the delegate that the text object has changed its characters or formatting attributes. The name of aNotification is TextViewDidChangeNotification.

textDidEndEditing

public abstract void textDidEndEditing(NSNotification aNotification)

Informs the delegate that the text object has finished editing (that it has resigned first responder status). The name of aNotification is TextViewDidEndEditingNotification.

textShouldBeginEditing

public abstract boolean textShouldBeginEditing(NSText aTextObject)

Invoked from a text object's implementation of becomeFirstResponder, this method requests permission for aTextObject to begin editing. If the delegate returns true, the text object proceeds to make changes. If the delegate returns false, the text object abandons the editing operation. This method is invoked whenever aTextObject attempts to become first responder.

See Also: makeFirstResponder (NSWindow), becomeFirstResponder (NSResponder)



textShouldEndEditing

public abstract boolean textShouldEndEditing(NSText aTextObject)

Invoked from a text object's implementation of resignFirstResponder, this method requests permission for aTextObject to end editing. If the delegate returns true, the text object proceeds to finish editing and resign first responder status. If the delegate returns false, the text object selects all of its text and remains the first responder.

See Also: resignFirstResponder (NSResponder)




Notifications


TextDidBeginEditingNotification

Posted when an NSText object begins any operation that changes characters or formatting attributes. The notification contains a notification object but no userInfo dictionary. The notification object is the notifying NSText object.

TextDidChangeNotification

Posted after an NSText object performs any operation that changes characters or formatting attributes. The notification contains a notification object but no userInfo dictionary. The notification object is the notifying NSText object.

TextDidEndEditingNotification

Description forthcoming.

Table of Contents