UIResponderStandardEditActions Protocol Reference

(informal protocol)

Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 3.0 and later.
Declared in
UIResponder.h

Overview

The UIResponderStandardEditActions informal protocol declares methods that responder classes should override to handle common editing commands invoked in the user interface, such as Copy, Paste, and Select.

Although this is an informal protocol—that is, a category declared on NSObject—it is recommended that responder classes (that is, immediate or distant ancestors of UIResponder) override its methods. Starting with the first responder, UIResponder looks for a responder object that can handle the method, and works up the responder chain from there. Responder classes may also implement the canPerformAction:withSender: method of UIResponder to disable or enable user-interface commands based on the context. The copy:, cut:, delete:, paste:, select:, and selectAll: methods are invoked when users tap the corresponding command in the menu managed by the UIMenuController shared instance.

Tasks

Handling Copy, Cut, Delete, and Paste Commands

Handling Selection Commands

Handling Styled Text Editing

Handling Writing Direction Changes

Instance Methods

copy:

Copy the selection to the pasteboard.

- (void)copy:(id)sender
Parameters
sender

The object calling this method.

Discussion

This method is invoked when the user taps the Copy command of the editing menu. A subclass of UIResponder typically implements this method. Using the methods of the UIPasteboard class, it should convert the selection into an appropriate object (if necessary) and write that object to a pasteboard. The command travels from the first responder up the responder chain until it is handled; it is ignored if no responder handles it. If a responder doesn’t handle the command in the current context, it should pass it to the next responder.

Availability
  • Available in iOS 3.0 and later.
Declared In
UIResponder.h

cut:

Remove the selection from the user interface and write it to the pasteboard.

- (void)cut:(id)sender
Parameters
sender

The object calling this method.

Discussion

This method is invoked when the user taps the Cut command of the editing menu. A subclass of UIResponder typically implements this method. Using the methods of the UIPasteboard class, it should convert the selection into an appropriate object (if necessary) and write that object to a pasteboard. It should also remove the selected object from the user interface and, if applicable, from the application’s data model. The command travels from the first responder up the responder chain until it is handled; it is ignored if no responder handles it. If a responder doesn’t handle the command in the current context, it should pass it to the next responder.

Availability
  • Available in iOS 3.0 and later.
Declared In
UIResponder.h

delete:

Remove the selection from the user interface.

- (void)delete:(id)sender;
Parameters
sender

The object calling this method.

Discussion

This method is invoked when the user taps the Delete command of the editing menu. A subclass of UIResponder typically implements this method by removing the selected object from the user interface and, if applicable, from the application’s data model. It should not write any data to the pasteboard. The command travels from the first responder up the responder chain until it is handled; it is ignored if no responder handles it. If a responder doesn’t handle the command in the current context, it should pass it to the next responder.

Availability
  • Available in iOS 3.2 and later.
See Also
Declared In
UIResponder.h

makeTextWritingDirectionLeftToRight:

Change the writing direction to left-to-right.

- (void)makeTextWritingDirectionLeftToRight:(id)sender
Parameters
sender

The object calling this method.

Discussion

A subclass of UIResponder typically implements this method by changing the current writing direction of its text editing area. The command travels from the first responder up the responder chain until it is handled; it is ignored if no responder handles it. If a responder doesn’t handle the command in the current context, it should pass it to the next responder.

Availability
  • Available in iOS 5.0 and later.
Declared In
UIResponder.h

makeTextWritingDirectionRightToLeft:

Change the writing direction to right-to-left.

- (void)makeTextWritingDirectionRightToLeft:(id)sender
Parameters
sender

The object calling this method.

Discussion

A subclass of UIResponder typically implements this method by changing the current writing direction of its text editing area. The command travels from the first responder up the responder chain until it is handled; it is ignored if no responder handles it. If a responder doesn’t handle the command in the current context, it should pass it to the next responder.

Availability
  • Available in iOS 5.0 and later.
Declared In
UIResponder.h

paste:

Read data from the pasteboard and display it in the user interface.

- (void)paste:(id)sender
Parameters
sender

The object calling this method.

Discussion

This method is invoked when the user taps the Paste command of the editing menu. A subclass of UIResponder typically implements this method. Using the methods of the UIPasteboard class, it should read the data in the pasteboard, convert the data into an appropriate internal representation (if necessary), and display it in the user interface. The command travels from the first responder up the responder chain until it is handled; it is ignored if no responder handles it. If a responder doesn’t handle the command in the current context, it should pass it to the next responder.

Availability
  • Available in iOS 3.0 and later.
Declared In
UIResponder.h

select:

Select the next object the user taps.

- (void)select:(id)sender
Parameters
sender

The object calling this method.

Discussion

This method is invoked when the user taps the Select command of the editing menu. This command is used for targeted selection of items in the receiving view that can be broken up into chunks. This could be, for example, words in a text view. Another example might be a view that puts lists of visible objects in multiple groups; the select: command could be implemented to select all the items in the same group as the currently selected item.

A subclass of UIResponder typically implements this method. The command travels from the first responder up the responder chain until it is handled; it is ignored if no responder handles it. If a responder doesn’t handle the command in the current context, it should pass it to the next responder.

Availability
  • Available in iOS 3.0 and later.
Declared In
UIResponder.h

selectAll:

Select all objects in the current view.

- (void)selectAll:(id)sender
Parameters
sender

The object calling this method.

Discussion

This method is invoked when the user taps the Select All command of the editing menu. A subclass of UIResponder typically implements this method by selecting all objects in the current view. The command travels from the first responder up the responder chain until it is handled; it is ignored if no responder handles it. If a responder doesn’t handle the command in the current context, it should pass it to the next responder.

Availability
  • Available in iOS 3.0 and later.
See Also
Declared In
UIResponder.h

toggleBoldface:

Toggle the bold style information of the selected text.

- (void)toggleBoldface:(id)sender
Parameters
sender

The object calling this method.

Discussion

A subclass of UIResponder typically implements this method by applying a boldface style to the selected text if it does not currently have it, or by removing the style if it does. The command travels from the first responder up the responder chain until it is handled; it is ignored if no responder handles it. If a responder doesn’t handle the command in the current context, it should pass it to the next responder.

Availability
  • Available in iOS 6.0 and later.
Declared In
UIResponder.h

toggleItalics:

Toggle the italic style information of the selected text.

- (void)toggleItalics:(id)sender
Parameters
sender

The object calling this method.

Discussion

A subclass of UIResponder typically implements this method by applying an italic style to the selected text if it does not currently have it, or by removing the style if it does. The command travels from the first responder up the responder chain until it is handled; it is ignored if no responder handles it. If a responder doesn’t handle the command in the current context, it should pass it to the next responder.

Availability
  • Available in iOS 6.0 and later.
Declared In
UIResponder.h

toggleUnderline:

Toggle the underline style information of the selected text.

- (void)toggleUnderline:(id)sender
Parameters
sender

The object calling this method.

Discussion

A subclass of UIResponder typically implements this method by applying an underline style to the selected text if it does not currently have it, or by removing the style if it does. The command travels from the first responder up the responder chain until it is handled; it is ignored if no responder handles it. If a responder doesn’t handle the command in the current context, it should pass it to the next responder.

Availability
  • Available in iOS 6.0 and later.
Declared In
UIResponder.h