Retired Document
Important: The information in this document has been superseded by the Text Editing chapter of Cocoa Text Architecture Guide.
Introduction to Text Editing Programming Guide for Cocoa
Text Editing Programming Guide for Cocoa describes ways in which you can control the behavior of the Cocoa text system as it performs text editing. Text editing is the modification of text characters or attributes by interacting with text objects. Usually, editing is performed by direct user action with a text view, but it can also be accomplished by programmatic interaction with a text storage object. This document also discusses the text input system that translates keyboard events into commands and text input.
Who Should Read This Document
You should read this programming topic if you need to understand how text editing in Cocoa works and how to modify that behavior.
To understand the information in this programming topic you should have prior general knowledge of the Cocoa text system’s capabilities and architecture, as well as basic Cocoa programming conventions.
Organization of This Document
This programming topic contains the following articles:
Overview of Text Editing provides a high-level view of the text editing mechanism and explains the message sequence that occurs when a text view receives a key event.
About Key Bindings describes the key-binding mechanism by which keyboard events are mapped to method names or processed as text input.
Intercepting Key Events explains how to catch key events received by an
NSTextView
object so that you can modify their effect.Delegate Messages and Notifications describes the messages the text view delegate and registered observers of the text system can receive.
Subclassing NSTextView explains the responsibilities an
NSTextView
subclass must fulfill to interact successfully with the text system.Creating Custom Views describes how to implement a custom text view that interacts with the text input system, in case
NSTextView
does not provide the support required by your application.Synchronizing Editing explains the batch editing concept and shows how to force the end of editing, which sends notifications and leaves the text backing store in a consistent state.
Setting Focus and Selection Programmatically explains how to make a text view the first responder and how to manipulate the selection programmatically.
Working With the Field Editor explains how the text system uses the field editor and how you can modify that behavior.
Handling Drops in a Text Field explains how to add drag-and-drop support to a text field, which includes providing a custom field editor for the text view.
See Also
Text System Overview provides an overview of the Cocoa text system, introducing its important features and describing aspects of the text system as a whole.
Text System User Interface Layer Programming Guide provides more information about the primary interface to the text system, the
NSTextView
class.TextLayoutDemo sample code illustrates customizing
NSTextView
withNSLayoutManager
and a customNSTextContainer
object.NSFontAttributeExplorer sample code demonstrates how to gather and display font metric information for installed fonts using
NSFont
.TextInputView sample code, in /Developer/Examples/AppKit, explains how to implement the
NSTextInputClient
protocol for custom views.
The other guides and programming topics in the text system area also have information related to text editing. In addition, please refer to the other text-related code samples installed with Xcode Tools in /Developer/Examples/AppKit, including complete source code for the TextEdit application that ships with OS X.
Copyright © 2003, 2013 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2013-04-23