NSTextDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in OS X v10.6 and later.
Companion guide
Text System Overview
Declared in
NSText.h
Related sample code

Overview

The NSTextDelegate protocol defines the optional methods implemented by delegates of NSText objects.

Tasks

Changing Text Formatting

Editing Text

Instance Methods

textDidBeginEditing:

Informs the delegate that the text object has begun editing (that the user has begun changing it).

- (void)textDidBeginEditing:(NSNotification *)aNotification
Discussion

The name of aNotification is NSTextDidBeginEditingNotification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSText.h

textDidChange:

Informs the delegate that the text object has changed its characters or formatting attributes.

- (void)textDidChange:(NSNotification *)aNotification
Discussion

The name of aNotification is NSTextDidChangeNotification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSText.h

textDidEndEditing:

Informs the delegate that the text object has finished editing (that it has resigned first responder status).

- (void)textDidEndEditing:(NSNotification *)aNotification
Discussion

The name of aNotification is NSTextDidEndEditingNotification.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSText.h

textShouldBeginEditing:

Invoked when a text object begins to change its text, this method requests permission for aTextObject to begin editing.

- (BOOL)textShouldBeginEditing:(NSText *)aTextObject
Discussion

If the delegate returns YES, the text object proceeds to make changes. If the delegate returns NO, the text object abandons the editing operation. This method is also invoked when the user drags and drops a file onto the text object.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSText.h

textShouldEndEditing:

Invoked from a text object’s implementation of resignFirstResponder, this method requests permission for aTextObject to end editing.

- (BOOL)textShouldEndEditing:(NSText *)aTextObject
Discussion

If the delegate returns YES, the text object proceeds to finish editing and resign first responder status. If the delegate returns NO, the text object selects all of its text and remains the first responder.

Availability
  • Available in OS X v10.0 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
See Also
Declared In
NSText.h