Conforms to NSObject
Declared in DTRichTextEditorView.h

Overview

The DTRichTextEditorViewDelegate protocol defines a set of optional methods you can use to receive editing-related messages for DTRichTextEditorView objects. All of the methods in this protocol are optional. You can use them in situations where you might want to adjust the text being edited (such as in the case of a spell checker program) or modify the intended insertion point.

Properties

menuItems

The delegate’s custom menu items to include in the editing menu.

@property (nonatomic, retain) NSArray *menuItems

Discussion

This property contains an array of UIMenuItem objects to display in the standard editing menu, an instance of UIMenuController. Menu items may not override the editor views standard functionality. For example, a menu item with action copy: will not be included in the menu. To override methods in the UIResponderStandardEditActions informal protocol you must subclass DTRichTextEditorView.

Declared In

DTRichTextEditorView.h

Instance Methods

editorView:canPerformAction:withSender:

Asks the delegate if the editing menu should omit or show the commands.

- (BOOL)editorView:(DTRichTextEditorView *)editorView canPerformAction:(SEL)action withSender:(id)sender

Parameters

editorView

The editor view which is making this request.

action

A selector type identifying the method to show in the editing menu. This includes the actions of the UIResponderStandardEditActions informal protocol, the DTRichTextEditorStandardEditActions protocol, and the actions of the delegate’s custom menuItems.

sender

The object calling this method. For the editing menu commands, this is the shared UIApplication object. Depending on the context, you can query the sender for information to help you determine whether a command should be enabled.

Return Value

YES if the the command identified by action should be enabled or NO if it should be disabled. Returning YES means that your class can handle your custom menu item command in the current context, or that the editor view is allowed to handle standard edit actions.

Discussion

The delegate can use this method to disable standard edit commands such as copy: and paste: by returning NO.

This method might be called more than once for the same action but with a different sender each time. You should be prepared for any kind of sender including nil.

Declared In

DTRichTextEditorView.h

editorView:shouldChangeTextInRange:replacementText:

Asks the delegate whether the specified text should be replaced in the text view.

- (BOOL)editorView:(DTRichTextEditorView *)editorView shouldChangeTextInRange:(NSRange)range replacementText:(NSAttributedString *)text

Parameters

editorView

The editor view containing the changes.

range

The current selection range. If the length of the range is 0, range reflects the current insertion point. If the user presses the Delete key, the length of the range is 1 and an empty string object replaces that single character.

text

The text to insert.

Return Value

YES if the old text should be replaced by the new text; NO if the replacement operation should be aborted.

Declared In

DTRichTextEditorView.h

editorView:willPasteText:inRange:

Notifies the delegate that text will be pasted at the given range. This gives the delegate an opportunity to modify content for a paste operation. A delegate may use this method to modify or remove specific attributes including disallowing image attachments. editorView:shouldChangeTextInRange:replacementText: is called before this method if implemented.

- (NSAttributedString *)editorView:(DTRichTextEditorView *)editorView willPasteText:(NSAttributedString *)text inRange:(NSRange)range

Parameters

editorView

The editor view undergoing a paste operation.

text

The text to paste.

range

The range in which to paste the text.

Return Value

An attributed string for the paste operation. Return text if suitable or a modified string. Return nil to cancel the paste operation.

Declared In

DTRichTextEditorView.h

editorViewDidBeginEditing:

Tells the delegate that editing of the specified editor view has begun.

- (void)editorViewDidBeginEditing:(DTRichTextEditorView *)editorView

Parameters

editorView

The editor view in which editing began.

Declared In

DTRichTextEditorView.h

editorViewDidChange:

Tells the delegate that the text or attributes in the specified editor view were changed by the user

- (void)editorViewDidChange:(DTRichTextEditorView *)editorView

Parameters

editorView

The editor view containing the changes.

Declared In

DTRichTextEditorView.h

editorViewDidChangeSelection:

Tells the delegate that the text selection changed in the specified editor view.

- (void)editorViewDidChangeSelection:(DTRichTextEditorView *)editorView

Parameters

editorView

The editor view whose selection changed.

Declared In

DTRichTextEditorView.h

editorViewDidEndEditing:

Tells the delegate that editing of the specified text view has ended.

- (void)editorViewDidEndEditing:(DTRichTextEditorView *)editorView

Parameters

editorView

The editor view in which editing ended.

Declared In

DTRichTextEditorView.h

editorViewShouldBeginEditing:

Asks the delegate if editing should begin in the specified editor view.

- (BOOL)editorViewShouldBeginEditing:(DTRichTextEditorView *)editorView

Parameters

editorView

The editor view for which editing is about to begin.

Return Value

YES if an editing session should be initiated; otherwise, NO to disallow editing.

Declared In

DTRichTextEditorView.h

editorViewShouldEndEditing:

Asks the delegate if editing should stop in the specified editor view.

- (BOOL)editorViewShouldEndEditing:(DTRichTextEditorView *)editorView

Parameters

editorView

The editor view for which editing is about to end.

Return Value

YES if editing should stop; otherwise, NO if the editing session should continue

Declared In

DTRichTextEditorView.h