NSTextView

NSTextView Mac OS X 10.0

This class is the frontend class to Cocoa's text-manipulation architecture. For most purposes, programmers can use this class to interface with the text system; however, if more control is desired, than they may work with the individual component classes of the text system, which are NSTextStorage, NSTextContainer, NSLayoutManager, and this class. In terms of the Model-View-Controller pattern, NSTextStorage is the model, NSTextView is the view, and NSLayoutManager and NSTextContainer serve as controllers for the data layer and the view layer.

figs/cocn_15110.gif

@interface NSTextView : NSText <NSTextInput>
 // Initializers
   - (id)initWithFrame:(NSRect)frameRect;
   - (id)initWithFrame:(NSRect)frameRect textContainer:(NSTextContainer *)container;
 // Accessor Methods
   - (void)setImportsGraphics:(BOOL)flag;
   - (BOOL)importsGraphics;
   - (void)setBackgroundColor:(NSColor *)color;
   - (NSColor *)backgroundColor;
   - (void)setAcceptsGlyphInfo:(BOOL)flag;
   - (BOOL)acceptsGlyphInfo;
   - (void)setSelectable:(BOOL)flag;
   - (void)setUsesRuler:(BOOL)flag;
   - (BOOL)usesRuler;
   - (void)setRulerVisible:(BOOL)flag;
   - (void)setRichText:(BOOL)flag;
   - (void)setTypingAttributes:(NSDictionary *)attrs;
   - (NSDictionary *)typingAttributes;
   - (void)setMarkedTextAttributes:(NSDictionary *)attributeDictionary;
   - (NSDictionary *)markedTextAttributes;
   - (void)setAlignment:(NSTextAlignment)alignment range:(NSRange)range;
   - (void)setDelegate:(id)anObject;
   - (id)delegate;
   - (void)setSelectedRange:(NSRange)charRange;
   - (void)setInsertionPointColor:(NSColor *)color;
   - (NSColor *)insertionPointColor;
   - (void)setAllowsUndo:(BOOL)flag;
   - (BOOL)allowsUndo;
   - (void)setSelectedTextAttributes:(NSDictionary *)attributeDictionary;
   - (NSDictionary *)selectedTextAttributes;
   - (void)setSelectionGranularity:(NSSelectionGranularity)granularity;
   - (NSSelectionGranularity)selectionGranularity;
   - (void)setFieldEditor:(BOOL)flag;
   - (void)setUsesFontPanel:(BOOL)flag;
   - (BOOL)usesFontPanel;
   - (void)setSelectedRange:(NSRange)charRange affinity:(NSSelectionAffinity)affinity
        stillSelecting:(BOOL)stillSelectingFlag;
   - (void)setSmartInsertDeleteEnabled:(BOOL)flag;
   - (BOOL)smartInsertDeleteEnabled;
   - (void)setNeedsDisplayInRect:(NSRect)rect avoidAdditionalLayout:(BOOL)flag;
   - (void)setTextContainerInset:(NSSize)inset;
   - (NSSize)textContainerInset;
   - (void)setTextContainer:(NSTextContainer *)container;
   - (NSTextContainer *)textContainer;
   - (void)setEditable:(BOOL)flag;
   - (void)setDrawsBackground:(BOOL)flag;
   - (BOOL)drawsBackground;
   - (void)setContinuousSpellCheckingEnabled:(BOOL)flag;
   - (void)setConstrainedFrameSize:(NSSize)desiredSize;
 // Class Methods
   + (void)registerForServices;
 // Instance Methods
   - (void)cleanUpAfterDragOperation;
   - (NSArray *)acceptableDragTypes;
   - (void)clickedOnLink:(id)link v
   - (void)alignJustified:(id)sender;
   - (void)changeColor:(id)sender;
   - (void)didChangeText;
   - (BOOL)becomeFirstResponder;
   - (NSImage *)dragImageForSelectionWithEvent:(NSEvent *)event origin:(NSPointPointer)origin;
   - (unsigned int)dragOperationForDraggingInfo:(id <NSDraggingInfo>)dragInfo type:(NSString *)type;
   - (BOOL)dragSelectionWithEvent:(NSEvent *)event  offset:(NSSize)mouseOffset slideBack:(BOOL)slideBack;
   - (void)insertText:(id)insertString;
   - (void)invalidateTextContainerOrigin;
   - (BOOL)isContinuousSpellCheckingEnabled;
   - (BOOL)isEditable;
   - (BOOL)isFieldEditor;
   - (BOOL)isRichText;
   - (BOOL)isSelectable;
   - (NSLayoutManager *)layoutManager;
   - (void)loosenKerning:(id)sender;
   - (void)lowerBaseline:(id)sender;
   - (NSString *)preferredPasteboardTypeFromArray:(NSArray *)availableTypes
        restrictedToTypesFromArray:(NSArray *)allowedTypes;
   - (void)raiseBaseline:(id)sender;
   - (NSRange)rangeForUserCharacterAttributeChange;
   - (NSRange)rangeForUserParagraphAttributeChange;
   - (NSRange)rangeForUserTextChange;
   - (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard;
   - (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard type:(NSString *)type;
   - (NSArray *)readablePasteboardTypes;
   - (void)replaceTextContainer:(NSTextContainer *)newContainer;
   - (BOOL)resignFirstResponder;
   - (void)drawInsertionPointInRect:(NSRect)rect color:(NSColor *)color turnedOn:(BOOL)flag;
   - (BOOL)isRulerVisible;
   - (void)pasteAsPlainText:(id)sender;
   - (void)pasteAsRichText:(id)sender;
   - (void)rulerView:(NSRulerView *)ruler didAddMarker:(NSRulerMarker *)marker;
   - (void)rulerView:(NSRulerView *)ruler didMoveMarker:(NSRulerMarker *)marker;
   - (void)rulerView:(NSRulerView *)ruler didRemoveMarker:(NSRulerMarker *)marker;
   - (void)rulerView:(NSRulerView *)ruler handleMouseDown:(NSEvent *)event;
   - (BOOL)rulerView:(NSRulerView *)ruler shouldAddMarker:(NSRulerMarker *)marker;
   - (BOOL)rulerView:(NSRulerView *)ruler shouldMoveMarker:(NSRulerMarker *)marker;
   - (BOOL)rulerView:(NSRulerView *)ruler shouldRemoveMarker:(NSRulerMarker *)marker;
   - (float)rulerView:(NSRulerView *)ruler willAddMarker:(NSRulerMarker *)marker atLocation:(float)location;
   - (float)rulerView:(NSRulerView *)ruler willMoveMarker:(NSRulerMarker *)marker toLocation:(float)location;
   - (NSSelectionAffinity)selectionAffinity;
   - (NSRange)selectionRangeForProposedRange:(NSRange)proposedCharRange
        granularity:(NSSelectionGranularity)granularity;
   - (BOOL)shouldChangeTextInRange:(NSRange)affectedCharRange replacementString:(NSString *)replacementString;
   - (BOOL)shouldDrawInsertionPoint;
   - (NSRange)smartDeleteRangeForProposedRange:(NSRange)proposedCharRange;
   - (NSString *)smartInsertAfterStringForString:(NSString *)pasteString
        replacingRange:(NSRange)charRangeToReplace;
   - (NSString *)smartInsertBeforeStringForString:(NSString *)pasteString replacingRange:(NSRange)charRangeToReplace;
   - (void)smartInsertForString:(NSString *)pasteString replacingRange:(NSRange)charRangeToReplace
        beforeString:(NSString **)beforeString afterString:(NSString **)afterString;
   - (int)spellCheckerDocumentTag;
   - (void)startSpeaking:(id)sender;
   - (void)stopSpeaking:(id)sender;
   - (NSPoint)textContainerOrigin;
   - (NSTextStorage *)textStorage;
   - (void)tightenKerning:(id)sender;
   - (void)toggleContinuousSpellChecking:(id)sender;
   - (void)toggleTraditionalCharacterShape:(id)sender;
   - (void)turnOffKerning:(id)sender;
   - (void)turnOffLigatures:(id)sender;
   - (void)updateDragTypeRegistration;
   - (void)updateFontPanel;
   - (void)updateInsertionPointStateAndRestartTimer:(BOOL)restartFlag;
   - (void)updateRuler;
   - (void)useAllLigatures:(id)sender;
   - (void)useStandardKerning:(id)sender;
   - (void)useStandardLigatures:(id)sender;
   - (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType;
   - (NSArray *)writablePasteboardTypes;
   - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard type:(NSString *)type;
   - (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types;
 // Methods Implementing NSTextInput
   - (void)insertText:(id)aString;
   - (void)doCommandBySelector:(SEL)aSelector;
   - (void)setMarkedText:(id)aString selectedRange:(NSRange)selRange;
   - (void)unmarkText;
   - (BOOL)hasMarkedText;
   - (long)conversationIdentifier;
   - (NSAttributedString *)attributedSubstringFromRange:(NSRange)theRange;
   - (NSRange)markedRange;
   - (NSRange)selectedRange;
   - (NSRect)firstRectForCharacterRange:(NSRange)theRange;
   - (unsigned int)characterIndexForPoint:(NSPoint)thePoint;
   - (NSArray*)validAttributesForMarkedText;
// Methods Implemented by the Delegate
   - (void)textView:(NSTextView *)textView clickedOnCell:(id <NSTextAttachmentCell>)cell
        inRect:(NSRect)cellFrame;
   - (void)textView:(NSTextView *)textView clickedOnCell:(id <NSTextAttachmentCell>)cell
        inRect:(NSRect)cellFrame atIndex:(unsigned)charIndex;
   - (BOOL)textView:(NSTextView *)textView clickedOnLink:(id)link;
   - (BOOL)textView:(NSTextView *)textView clickedOnLink:(id)link atIndex:(unsigned)charIndex;
   - (BOOL)textView:(NSTextView *)textView doCommandBySelector:(SEL)commandSelector;
   - (void)textView:(NSTextView *)textView doubleClickedOnCell:(id <NSTextAttachmentCell>)cell
        inRect:(NSRect)cellFrame;
   - (void)textView:(NSTextView *)textView doubleClickedOnCell:(id <NSTextAttachmentCell>)cell
        inRect:(NSRect)cellFrame atIndex:(unsigned)charIndex;
   - (BOOL)textView:(NSTextView *)textView shouldChangeTextInRange:(NSRange)affectedCharRange
        replacementString:(NSString *)replacementString;
   - (NSRange)textView:(NSTextView *)textView
        willChangeSelectionFromCharacterRange:(NSRange)oldSelectedCharRange
        toCharacterRange:(NSRange)newSelectedCharRange;
   - (void)textView:(NSTextView *)view draggedCell:(id <NSTextAttachmentCell>)cell
        inRect:(NSRect)rect event:(NSEvent *)event;
   - (void)textView:(NSTextView *)view draggedCell:(id <NSTextAttachmentCell>)cell inRect:(NSRect)rect 
        event:(NSEvent *)event atIndex:(unsigned)charIndex;
   - (NSArray *)textView:(NSTextView *)view writablePasteboardTypesForCell:(id <NSTextAttachmentCell>)cell
        atIndex:(unsigned)charIndex;
   - (BOOL)textView:(NSTextView *)view writeCell:(id <NSTextAttachmentCell>)cell atIndex:(unsigned)charIndex
        toPasteboard:(NSPasteboard *)pboard type:(NSString *)type;
   - (void)textViewDidChangeSelection:(NSNotification *)notification;
   - (NSUndoManager *)undoManagerForTextView:(NSTextView *)view;
// Notifications
   NSTextViewDidChangeSelectionNotification;
   NSTextViewWillChangeNotifyingTextViewNotification;



    Part II: API Quick Reference
    Chapter 13. Foundation Classes