Mac Developer Library

Developer

AppKit Framework Reference NSTextDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSTextDelegate

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

Inheritance


Not Applicable

Import Statement


import AppKit @import AppKit;

Availability


Available in OS X v10.6 and later.
  • Informs the delegate that the text object has changed its characters or formatting attributes.

    Declaration

    Swift

    optional func textDidChange(_ notification: NSNotification)

    Objective-C

    - (void)textDidChange:(NSNotification *)notification

    Discussion

    The name of aNotification is NSTextDidChangeNotification.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

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

    Declaration

    Swift

    optional func textShouldBeginEditing(_ textObject: NSText) -> Bool

    Objective-C

    - (BOOL)textShouldBeginEditing:(NSText *)textObject

    Discussion

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

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

    See Also

    – makeFirstResponder: (NSWindow)
    – becomeFirstResponder (NSResponder)

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

    Declaration

    Swift

    optional func textDidBeginEditing(_ notification: NSNotification)

    Objective-C

    - (void)textDidBeginEditing:(NSNotification *)notification

    Discussion

    The name of aNotification is NSTextDidBeginEditingNotification.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

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

    Declaration

    Swift

    optional func textShouldEndEditing(_ textObject: NSText) -> Bool

    Objective-C

    - (BOOL)textShouldEndEditing:(NSText *)textObject

    Discussion

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

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.

    See Also

    – resignFirstResponder (NSResponder)

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

    Declaration

    Swift

    optional func textDidEndEditing(_ notification: NSNotification)

    Objective-C

    - (void)textDidEndEditing:(NSNotification *)notification

    Discussion

    The name of aNotification is NSTextDidEndEditingNotification.

    Import Statement

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    Available as part of an informal protocol prior to OS X v10.6.