Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/AppKit.framework |
Availability | Available in Mac OS X v10.0 and later. |
Companion guide | |
Declared in | NSInterfaceStyle.h NSResponder.h |
Related sample code |
NSResponder
is an abstract class that forms the basis of event and command processing in the Application Kit. The core classes—NSApplication
, NSWindow
, and NSView
—inherit from NSResponder
, as must any class that handles events. The responder model is built around three components: event messages, action messages, and the responder chain.
Starting with Mac OS X v10.4, NSResponder
plays an important role in the presentation of error information. The default implementations of the presentError:
and presentError:modalForWindow:delegate:didPresentSelector:contextInfo:
methods send willPresentError:
to self
, thereby giving subclasses the opportunity to customize the localized information presented in error alerts. NSResponder
then forwards the message to the next responder, passing it the customized NSError
object. The exact path up the modified responder chain depends on the type of application window:
Windows owned by document: view to superviews to window to window controller to document object to document controller to the application object
Windows with window controllers but no documents: view to superviews to window to window controller to the application object
Windows with no window controllers: view to superviews to window to the application object
NSApplication
displays a document-modal error alert and, if the error object has a recovery attempter, gives it a chance to recover from the error. (A recovery attempter is an object that conforms to the NSErrorRecoveryAttempting
informal protocol.)
– mouseDown:
– mouseDragged:
– mouseUp:
– mouseMoved:
– mouseEntered:
– mouseExited:
– rightMouseDown:
– rightMouseDragged:
– rightMouseUp:
– otherMouseDown:
– otherMouseDragged:
– otherMouseUp:
– keyDown:
– keyUp:
– interpretKeyEvents:
– performKeyEquivalent:
– performMnemonic:
– flushBufferedKeyEvents
– cancelOperation:
– capitalizeWord:
– centerSelectionInVisibleArea:
– changeCaseOfLetter:
– complete:
– deleteBackward:
– deleteBackwardByDecomposingPreviousCharacter:
– deleteForward:
– deleteToBeginningOfLine:
– deleteToBeginningOfParagraph:
– deleteToEndOfLine:
– deleteToEndOfParagraph:
– deleteToMark:
– deleteWordBackward:
– deleteWordForward:
– indent:
– insertBacktab:
– insertContainerBreak:
– insertLineBreak:
– insertNewline:
– insertNewlineIgnoringFieldEditor:
– insertParagraphSeparator:
– insertTab:
– insertTabIgnoringFieldEditor:
– insertText:
– lowercaseWord:
– moveBackward:
– moveBackwardAndModifySelection:
– moveDown:
– moveDownAndModifySelection:
– moveForward:
– moveForwardAndModifySelection:
– moveLeft:
– moveLeftAndModifySelection:
– moveRight:
– moveRightAndModifySelection:
– moveToBeginningOfDocument:
– moveToBeginningOfLine:
– moveToBeginningOfParagraph:
– moveToEndOfDocument:
– moveToEndOfLine:
– moveToEndOfParagraph:
– moveUp:
– moveUpAndModifySelection:
– moveWordBackward:
– moveWordBackwardAndModifySelection:
– moveWordForward:
– moveWordForwardAndModifySelection:
– moveWordLeft:
– moveWordRight:
– moveWordRightAndModifySelection:
– moveWordLeftAndModifySelection:
– pageDown:
– pageUp:
– scrollLineDown:
– scrollLineUp:
– scrollPageDown:
– scrollPageUp:
– selectAll:
– selectLine:
– selectParagraph:
– selectToMark:
– selectWord:
– setMark:
– showContextHelp:
– swapWithMark:
– transpose:
– transposeWords:
– uppercaseWord:
– yank:
– presentError:
– presentError:modalForWindow:delegate:didPresentSelector:contextInfo:
– willPresentError:
Overridden by subclasses to return YES
if the receiver accepts first responder status.
- (BOOL)acceptsFirstResponder
As first responder, the receiver is the first object in the responder chain to be sent key events and action messages. The NSResponder
implementation returns NO
, indicating that by default a responder object doesn’t agree to become first responder.
NSResponder.h
Notifies the receiver that it’s about to become first responder in its NSWindow
.
- (BOOL)becomeFirstResponder
The default implementation returns YES
, accepting first responder status. Subclasses can override this method to update state or perform some action such as highlighting the selection, or to return NO
, refusing first responder status.
Use the NSWindow
makeFirstResponder:
method, not this method, to make an object the first responder. Never invoke this method directly.
NSResponder.h
Implemented by subclasses to cancel the current operation.
- (void)cancelOperation:(id)sender
The object invoking this method.
This method is bound to the Escape and Command-. (period) keys. The key window first searches the view hierarchy for a view whose key equivalent is Escape or Command-., whichever was entered. If none of these views handles the key equivalent, the window sends a default action message of cancelOperation:
to the first responder and from there the message travels up the responder chain.
If no responder in the responder chain implements cancelOperation:
, the key window searches the view hierarchy for a view whose key equivalent is Escape (note that this may be redundant if the original key equivalent was Escape). If no such responder is found, then a cancel:
action message is sent to the first responder in the responder chain that implements it.
NSResponder
declares but does not implement this method.
NSResponder.h
Implemented by subclasses to capitalize the word or words surrounding the insertion point or selection, expanding the selection if necessary.
- (void)capitalizeWord:(id)sender
The object invoking the method.
If either end of the selection partially covers a word, that entire word is made lowercase. The sender argument is typically the object that invoked this method. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to scroll the selection, whatever it is, inside its visible area.
- (void)centerSelectionInVisibleArea:(id)sender
The object that invoked the method (typically).
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to change the case of a letter or letters in the selection, perhaps by opening a panel with capitalization options or by cycling through possible case combinations.
- (void)changeCaseOfLetter:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to complete an operation in progress or a partially constructed element.
- (void)complete:(id)sender
Typically the object that invoked this method.
This method can be interpreted, for example, as a request to attempt expansion of a partial word, such as for expanding a glossary shortcut, or to close a graphics item being drawn. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Informs the receiver that the mouse cursor has moved into a cursor rectangle.
- (void)cursorUpdate:(NSEvent *)event
An object encapsulating information about the cursor-update event (NSCursorUpdate
).
Override this method to set the cursor image. The default implementation uses cursor rectangles, if cursor rectangles are currently valid. If they are not, it calls super
to send the message up the responder chain.
If the responder implements this method, but decides not to handle a particular event, it should invoke the superclass implementation of this method.
NSResponder.h
Implemented by subclasses to delete the selection, if there is one, or a single element backward from the insertion point (a letter or character in text, for example).
- (void)deleteBackward:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to delete the selection, if there is one, or a single character backward from the insertion point.
- (void)deleteBackwardByDecomposingPreviousCharacter:(id)sender
Typically the object that invoked this method.
If the previous character is canonically decomposable, this method should try to delete only the last character in the grapheme cluster (for example, deleting “a”+ “´” results in “a”). NSResponder
declares but does not implement this method.
NSResponder.h
Implemented by subclasses to delete the selection, if there is one, or a single element forward from the insertion point (a letter or character in text, for example).
- (void)deleteForward:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to delete the selection, if there is one, or all text from the insertion point to the beginning of a line (typically of text).
- (void)deleteToBeginningOfLine:(id)sender
Typically the object that invoked this method.
Also places the deleted text into the kill buffer. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to delete the selection, if there is one, or all text from the insertion point to the beginning of a paragraph of text.
- (void)deleteToBeginningOfParagraph:(id)sender
Typically the object that invoked this method.
Also places the deleted text into the kill buffer. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to delete the selection, if there is one, or all text from the insertion point to the end of a line (typically of text).
- (void)deleteToEndOfLine:(id)sender
Typically the object that invoked this method.
Also places the deleted text into the kill buffer. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to delete the selection, if there is one, or all text from the insertion point to the end of a paragraph of text.
- (void)deleteToEndOfParagraph:(id)sender
Typically the object that invoked this method.
Also places the deleted text into the kill buffer. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to delete the selection, if there is one, or all items from the insertion point to a previously placed mark, including the selection itself if not empty.
- (void)deleteToMark:(id)sender
Typically the object that invoked this method.
Also places the deleted text into the kill buffer. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to delete the selection, if there is one, or a single word backward from the insertion point.
- (void)deleteWordBackward:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to delete the selection, if there is one, or a single word forward from the insertion point.
- (void)deleteWordForward:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Attempts to perform the indicated command.
- (void)doCommandBySelector:(SEL)aSelector
The selector identifying the method.
If the receiver responds to aSelector, it invokes the method with nil
as the argument. If the receiver doesn’t respond, it sends this message to its next responder with the same selector. NSWindow
and NSApplication
also send the message to their delegates. If the receiver has no next responder or delegate, it beeps.
– tryToPerform:with:
– sendAction:to:from:
(NSApplication)NSResponder.h
Informs the receiver that the user has pressed or released a modifier key (Shift, Control, and so on).
- (void)flagsChanged:(NSEvent *)theEvent
An object encapsulating information about the modifier-key event.
The default implementation simply passes this message to the next responder.
NSResponder.h
Overridden by subclasses to clear any unprocessed key events.
- (void)flushBufferedKeyEvents
NSResponder.h
Displays context-sensitive help for the receiver if such exists; otherwise passes this message to the next responder.
- (void)helpRequested:(NSEvent *)theEvent
An object encapsulating information about the help-request event.
NSWindow
invokes this method automatically when the user clicks for help—while processing theEvent. Subclasses need not override this method, and application code shouldn’t directly invoke it.
NSResponder.h
Implemented by subclasses to indent the selection or the insertion point if there is no selection.
- (void)indent:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to handle a backward tab.”
- (void)insertBacktab:(id)sender
Typically the object that invoked this method.
A field editor might respond to this method by selecting the field before it, while a regular text object either doesn’t respond to or ignores such a message. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to insert a container break (typically a page break) at the insertion point or selection, deleting the selection if there is one.
- (void)insertContainerBreak:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method. NSTextView
implements it to insert an NSFormFeedCharacter
character (0x000c).
NSResponder.h
Implemented by subclasses to insert a line break (as distinguished from a paragraph break) at the insertion point or selection, deleting the selection if there is one.
- (void)insertLineBreak:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method. NSTextView
implements it to insert an NSLineSeparatorCharacter
character (0x2028).
NSResponder.h
Implemented by subclasses to insert a newline character at the insertion point or selection, deleting the selection if there is one, or to end editing if the receiver is a text field or other field editor.
- (void)insertNewline:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to insert a line-break character at the insertion point or selection, deleting the selection if there is one.
- (void)insertNewlineIgnoringFieldEditor:(id)sender
Typically the object that invoked this method.
Unlike insertNewline:
, this method always inserts a line-break character and doesn’t cause the receiver to end editing. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to insert a paragraph separator at the insertion point or selection, deleting the selection if there is one.
- (void)insertParagraphSeparator:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to insert a tab character at the insertion point or selection, deleting the selection if there is one, or to end editing if the receiver is a text field or other field editor.
- (void)insertTab:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to insert a tab character at the insertion point or selection, deleting the selection if there is one.
- (void)insertTabIgnoringFieldEditor:(id)sender
Typically the object that invoked this method.
Unlike insertTab:
, this method always inserts a tab character and doesn’t cause the receiver to end editing. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Overridden by subclasses to insert the supplied string at the insertion point or selection, deleting the selection if there is one.
- (void)insertText:(id)aString
The string to insert or replace the selection with. aString can be either an NSString
object or an NSAttributedString
object.
This method is often invoked by the system input manager after the receiver sends a interpretKeyEvents: message. The NSResponder
implementation simply passes this message to the next responder, or beeps if there is no next responder.
NSResponder.h
Returns the receiver’s interface style.
- (NSInterfaceStyle)interfaceStyle
interfaceStyle
is an abstract method in NSResponder
and just returns NSNoInterfaceStyle
. It is overridden in classes such as NSWindow
and NSView
to return the interface style, such as NSMacintoshInterfaceStyle
. A responder’s style (if other than NSNoInterfaceStyle
) overrides all other settings, such as those established by the defaults system.
NSInterfaceStyle.h
Invoked by subclasses from their keyDown:
method to handle a series of key events.
- (void)interpretKeyEvents:(NSArray *)eventArray
An array of key-event characters to give to the system input manager.
This method sends the character input in eventArray to the system input manager for interpretation as text to insert or commands to perform. The input manager responds to the request by sending insertText:
and doCommandBySelector:
messages back to the invoker of this method. Subclasses shouldn’t override this method.
See the NSInputManager
and NSTextInput
class and protocol specifications for more information on input management.
NSResponder.h
Informs the receiver that the user has pressed a key.
- (void)keyDown:(NSEvent *)theEvent
An object encapsulating information about the key-down event.
The receiver can interpret theEvent itself, or pass it to the system input manager using interpretKeyEvents:
. The default implementation simply passes this message to the next responder.
NSResponder.h
Informs the receiver that the user has released a key.
- (void)keyUp:(NSEvent *)theEvent
An object encapsulating information about the key-up event.
The default implementation simply passes this message to the next responder.
NSResponder.h
Implemented by subclasses to make lowercase every letter in the word or words surrounding the insertion point or selection, expanding the selection if necessary.
- (void)lowercaseWord:(id)sender
Typically the object that invoked this method.
If either end of the selection partially covers a word, that entire word is made lowercase. NSResponder
declares, but doesn’t implement this method.
NSResponder.h
Returns the receiver’s menu.
- (NSMenu *)menu
For NSApplication
this menu is the same as the menu returned by its mainMenu
method.
– setMenu:
– menuForEvent:
(NSView)+ defaultMenu
(NSView)NSResponder.h
Informs the receiver that the user has pressed the left mouse button.
- (void)mouseDown:(NSEvent *)theEvent
An object encapsulating information about the mouse-down event.
The default implementation simply passes this message to the next responder.
NSResponder.h
Informs the receiver that the user has moved the mouse with the left button pressed.
- (void)mouseDragged:(NSEvent *)theEvent
An object encapsulating information about the mouse-dragged event.
The default implementation simply passes this message to the next responder.
NSResponder.h
Informs the receiver that the cursor has entered a tracking rectangle.
- (void)mouseEntered:(NSEvent *)theEvent
An object encapsulating information about the mouse-entered event.
The default implementation simply passes this message to the next responder.
NSResponder.h
Informs the receiver that the cursor has exited a tracking rectangle.
- (void)mouseExited:(NSEvent *)theEvent
An object encapsulating information about the mouse-exited event.
The default implementation simply passes this message to the next responder.
NSResponder.h
Informs the receiver that the mouse has moved specified.
- (void)mouseMoved:(NSEvent *)theEvent
An object encapsulating information about the mouse-moved event.
The default implementation simply passes this message to the next responder.
– setAcceptsMouseMovedEvents:
(NSWindow)NSResponder.h
Informs the receiver that the user has released the left mouse button.
- (void)mouseUp:(NSEvent *)theEvent
An object encapsulating information about the mouse-up event.
The default implementation simply passes this message to the next responder.
NSResponder.h
Implemented by subclasses to move the selection or insertion point one element or character backward.
- (void)moveBackward:(id)sender
Typically the object that invoked this method.
In text, if there is a selection it should be deselected, and the insertion point should be placed at the beginning of the former selection. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to expand or reduce either end of the selection backward by one element or character.
- (void)moveBackwardAndModifySelection:(id)sender
Typically the object that invoked this method.
If the end being modified is the backward end, this method expands the selection; if the end being modified is the forward end, it reduces the selection. The first moveBackwardAndModifySelection:
or moveForwardAndModifySelection:
method in a series determines the end being modified by always expanding. Hence, this method results in the backward end becoming the mobile one if invoked first. By default, moveLeftAndModifySelection:
is bound to the left arrow key.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to move the selection or insertion point one element or character down.
- (void)moveDown:(id)sender
Typically the object that invoked this method.
In text, if there is a selection it should be deselected, and the insertion point should be placed below the beginning of the former selection. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to expand or reduce the top or bottom end of the selection downward by one element, character, or line (whichever is appropriate for text direction).
- (void)moveDownAndModifySelection:(id)sender
Typically the object that invoked this method.
If the end being modified is the bottom, this method expands the selection; if the end being modified is the top, it reduces the selection. The first moveDownAndModifySelection:
or moveUpAndModifySelection:
method in a series determines the end being modified by always expanding. Hence, this method results in the bottom end becoming the mobile one if invoked first.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to move the selection or insertion point one element or character forward.
- (void)moveForward:(id)sender
Typically the object that invoked this method.
In text, if there is a selection it should be deselected, and the insertion point should be placed at the end of the former selection. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to expand or reduce either end of the selection forward by one element or character.
- (void)moveForwardAndModifySelection:(id)sender
Typically the object that invoked this method.
If the end being modified is the backward end, this method reduces the selection; if the end being modified is the forward end, it expands the selection. The first moveBackwardAndModifySelection:
or moveForwardAndModifySelection:
method in a series determines the end being modified by always expanding. Hence, this method results in the forward end becoming the mobile one if invoked first. By default, moveRightAndModifySelection:
is bound to the right arrow key.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to move the selection or insertion point one element or character to the left.
- (void)moveLeft:(id)sender
Typically the object that invoked this method.
In text, if there is a selection it should be deselected, and the insertion point should be placed at the left end of the former selection. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to expand or reduce either end of the selection to the left (display order) by one element or character.
- (void)moveLeftAndModifySelection:(id)sender
Typically the object that invoked this method.
If the end being modified is the left end, this method expands the selection; if the end being modified is the right end, it reduces the selection. The first moveLeftAndModifySelection:
or moveRightAndModifySelection:
method in a series determines the end being modified by always expanding. Hence, this method results in the left end becoming the mobile one if invoked first. By default, this method is bound to the left arrow key.
NSResponder
declares but doesn’t implement this method.
The essential difference between this method and the corresponding moveBackwardAndModifySelection:
is that the latter method moves in logical order, which can differ in bidirectional text, whereas this method moves in display order.
NSResponder.h
Implemented by subclasses to move the selection or insertion point one element or character to the right.
- (void)moveRight:(id)sender
Typically the object that invoked this method.
In text, if there is a selection it should be deselected, and the insertion point should be placed at the right end of the former selection. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to expand or reduce either end of the selection to the right (display order) by one element or character.
- (void)moveRightAndModifySelection:(id)sender
Typically the object that invoked this method.
If the end being modified is the left end, this method reduces the selection; if the end being modified is the right end, it expands the selection. The first moveLeftAndModifySelection:
or moveRightAndModifySelection:
method in a series determines the end being modified by always expanding. Hence, this method results in the right end becoming the mobile one if invoked first. By default, this method is bound to the right arrow key.
NSResponder
declares but doesn’t implement this method.
The essential difference between this method and the corresponding moveForwardAndModifySelection:
is that the latter method moves in logical order, which can differ in bidirectional text, whereas this method moves in display order.
NSResponder.h
Implemented by subclasses to move the selection to the first element of the document or the insertion point to the beginning.
- (void)moveToBeginningOfDocument:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to move the selection to the first element of the selected line or the insertion point to the beginning of the line.
- (void)moveToBeginningOfLine:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to move the insertion point to the beginning of the selected paragraph.
- (void)moveToBeginningOfParagraph:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to move the selection to the last element of the document or the insertion point to the end.
- (void)moveToEndOfDocument:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to move the selection to the last element of the selected line or the insertion point to the end of the line.
- (void)moveToEndOfLine:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to move the insertion point to the end of the selected paragraph.
- (void)moveToEndOfParagraph:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to move the selection or insertion point one element or character up.
- (void)moveUp:(id)sender
Typically the object that invoked this method.
In text, if there is a selection it should be deselected, and the insertion point should be placed above the beginning of the former selection. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to expand or reduce the top or bottom end of the selection upward by one element, character, or line (whichever is appropriate for text direction).
- (void)moveUpAndModifySelection:(id)sender
Typically the object that invoked this method.
If the end being modified is the bottom, this method reduces the selection; if the end being modified is the top, it expands the selection. The first moveDownAndModifySelection:
or moveUpAndModifySelection:
method in a series determines the end being modified by always expanding. Hence, this method results in the top end becoming the mobile one if invoked first.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to move the selection or insertion point one word backward.
- (void)moveWordBackward:(id)sender
Typically the object that invoked this method.
If there is a selection it should be deselected, and the insertion point should be placed at the end of the first word preceding the former selection. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to expand or reduce either end of the selection backward by one whole word.
- (void)moveWordBackwardAndModifySelection:(id)sender
Typically the object that invoked this method.
If the end being modified is the backward end, this method expands the selection; if the end being modified is the forward end, it reduces the selection. The first moveWordBackwardAndModifySelection:
or moveWordForwardAndModifySelection:
method in a series determines the end being modified by always expanding. Hence, this method results in the backward end becoming the mobile one if invoked first.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to move the selection or insertion point one word forward, in logical order.
- (void)moveWordForward:(id)sender
Typically the object that invoked this method.
If there is a selection it should be deselected, and the insertion point should be placed at the beginning of the first word following the former selection. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to expand or reduce either end of the selection forward by one whole word.
- (void)moveWordForwardAndModifySelection:(id)sender
Typically the object that invoked this method.
If the end being modified is the backward end, this method reduces the selection; if the end being modified is the forward end, it expands the selection. The first moveWordBackwardAndModifySelection:
or moveWordForwardAndModifySelection:
method in a series determines the end being modified by always expanding. Hence, this method results in the forward end becoming the mobile one if invoked first. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to move the selection or insertion point one word to the left, in display order.
- (void)moveWordLeft:(id)sender
Typically the object that invoked this method.
If there is a selection it should be deselected, and the insertion point should be placed at the end of the first word to the left of the former selection. NSResponder
declares but doesn’t implement this method.
The main difference between this method and the corresponding moveWordBackward:
method is that the latter moves in logical order, which is important in bidirectional text, whereas this method moves in display order.
NSResponder.h
Implemented by subclasses to expand or reduce either end of the selection left by one whole word in display order.
- (void)moveWordLeftAndModifySelection:(id)sender
Typically the object that invoked this method.
If the end being modified is the left end, this method expands the selection; if the end being modified is the right end, it reduces the selection. The first moveWordLeftAndModifySelection:
or moveWordRightAndModifySelection:
method in a series determines the end being modified by always expanding. Hence, this method results in the left end becoming the mobile one if invoked first.
NSResponder
declares but doesn’t implement this method.
The main difference between this method and the corresponding moveWordBackwardAndModifySelection:
method is that the latter moves in logical order, which is important in bidirectional text, whereas this method moves in display order.
NSResponder.h
Implemented by subclasses to move the selection or insertion point one word right.
- (void)moveWordRight:(id)sender
Typically the object that invoked this method.
If there is a selection it should be deselected, and the insertion point should be placed at the beginning of the first word to the right of the former selection. NSResponder
declares but doesn’t implement this method.
The main difference between this method and the corresponding moveWordForward:
method is that the latter moves in logical order, which is important in bidirectional text, whereas this method moves in display order.
NSResponder.h
Implemented by subclasses to expand or reduce either end of the selection to the right by one whole word.
- (void)moveWordRightAndModifySelection:(id)sender
Typically the object that invoked this method.
If the end being modified is the backward end, this method reduces the selection; if the end being modified is the forward end, it expands the selection. The first moveWordBackwardAndModifySelection:
or moveWordForwardAndModifySelection:
method in a series determines the end being modified by always expanding. Hence, this method results in the forward end becoming the mobile one if invoked first. NSResponder
declares but doesn’t implement this method.
The main difference between this method and the corresponding moveWordForwardAndModifySelection:
method is that the latter moves in logical order, which is important in bidirectional text, whereas this method moves in display order.
NSResponder.h
Returns the receiver’s next responder, or nil
if it has none.
- (NSResponder *)nextResponder
NSResponder.h
Handles the case where an event or action message falls off the end of the responder chain.
- (void)noResponderFor:(SEL)eventSelector
A selector identifying the action or event message.
The default implementation beeps if eventSelector is keyDown:
.
NSResponder.h
Informs the receiver that the user has pressed a mouse button other than the left or right one.
- (void)otherMouseDown:(NSEvent *)theEvent
An object encapsulating information about the mouse-down event.
The default implementation simply passes this message to the next responder.
NSResponder.h
Informs the receiver that the user has moved the mouse with a button other than the left or right button pressed.
- (void)otherMouseDragged:(NSEvent *)theEvent
An object encapsulating information about the mouse-dragged event.
The default implementation simply passes this message to the next responder.
NSResponder.h
Informs the receiver that the user has released a mouse button other than the left or right button.
- (void)otherMouseUp:(NSEvent *)theEvent
An object encapsulating information about the mouse-up event.
The default implementation simply passes this message to the next responder.
NSResponder.h
Implemented by subclasses to scroll the receiver down (or back) one page in its scroll view, also moving the insertion point to the top of the newly displayed page.
- (void)pageDown:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to scroll the receiver up (or forward) one page in its scroll view, also moving the insertion point to the top of the newly displayed page.
- (void)pageUp:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Overridden by subclasses to handle a key equivalent.
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
An event object that represents the key equivalent pressed.
If the character code or codes in theEvent match the receiver’s key equivalent, the receiver should respond to the event and return YES
. The default implementation does nothing and returns NO
.
Note: performKeyEquivalent:
takes an NSEvent
object as its argument, while performMnemonic:
takes an NSString
object containing the uninterpreted characters of the key event. You should extract the characters for a key equivalent using the NSEvent
method charactersIgnoringModifiers
.
– performKeyEquivalent:
(NSView)– performKeyEquivalent:
(NSButton)NSResponder.h
Overridden by subclasses to handle a mnemonic.
- (BOOL)performMnemonic:(NSString *)aString
A string containing mnemonic character code or codes.
If the character code or codes in aString match the receiver’s mnemonic, the receiver should perform the mnemonic and return YES
. The default implementation does nothing and returns NO
. Mnemonics are not supported in Mac OS X.
– performMnemonic:
(NSView)NSResponder.h
Presents an error alert to the user as an application-modal dialog.
- (BOOL)presentError:(NSError *)anError
An object containing information about an error.
The alert displays information found in the NSError
object anError; this information can include error description, recovery suggestion, failure reason, and button titles (all localized). The method returns YES
if error recovery succeeded and NO
otherwise. For error recovery to be attempted, an recovery-attempter object (that is, an object conforming to the NSErrorRecoveryAttempting
informal protocol) must be associated with anError.
The default implementation of this method sends willPresentError:
to self
. By doing this, NSResponder
gives subclasses an opportunity to customize error presentation. It then forwards the message, passing any customized error object, to the next responder; if there is no next responder, it passes the error object to NSApp
, which displays a document-modal error alert. When the user dismisses the alert, any recovery attempter associated with the error object is given a chance to recover from the error. See the class description for the precise route up the responder chain (plus document and controller objects) this message might travel.
It is not recommended that you attempt to override this method. If you wish to customize the error presentation, override willPresentError:
instead.
NSResponder.h
Presents an error alert to the user as a document-modal sheet attached to document window.
- (void)presentError:(NSError *)error modalForWindow:(NSWindow *)aWindow delegate:(id)delegate didPresentSelector:(SEL)didPresentSelector contextInfo:(void *)contextInfo
The object encapsulating information about the error.
The window object identifying the window owning the document-modal sheet.
The modal delegate for the sheet.
A selector identifying the message to be sent to the modal delegate. The didPresentSelector selector must have the signature:
- (void)didPresentErrorWithRecovery:(BOOL)didRecover |
contextInfo:(void *)contextInfo |
Supplemental data to be passed to the modal delegate; can be NULL
.
The information displayed in the alert is extracted from the NSError
object error; it may include a description, recovery suggestion, failure reason, and button titles (all localized). Once the user dismisses the alert and any recovery attempter associated with the error object has had a chance to recover from it, the receiver sends a message identified by didPresentSelector to the modal delegate delegate. (A recovery attempter is an object that conforms to the NSErrorRecoveryAttempting
informal protocol.)
The modal delegate implements the method identified by didPresentSelector to perform any post-error processing if recovery failed or was not attempted (that is, didRecover is NO
). Any supplemental data is passed to the modal delegate via contextInfo.
The default implementation of this method sends willPresentError:
to self
. By doing this, NSResponder
gives subclasses an opportunity to customize error presentation. It then forwards the message, passing any customized error, to the next responder or; if there is no next responder, it passes the error object to NSApp
, which displays a document-modal error alert. When the user dismisses the alert, any recovery attempter associated with the error object is given a chance to recover from the error. See the class description for the precise route up the responder chain (plus document and controller objects) this message might travel.
It is not recommended that you attempt to override this method. If you wish to customize the error presentation, override willPresentError:
instead.
NSResponder.h
Notifies the receiver that it’s been asked to relinquish its status as first responder in its window.
- (BOOL)resignFirstResponder
The default implementation returns YES
, resigning first responder status. Subclasses can override this method to update state or perform some action such as unhighlighting the selection, or to return NO
, refusing to relinquish first responder status.
Use the NSWindow
makeFirstResponder:
method, not this method, to make an object the first responder. Never invoke this method directly.
NSResponder.h
Informs the receiver that the user has pressed the right mouse button.
- (void)rightMouseDown:(NSEvent *)theEvent
An object encapsulating information about the mouse-down event.
The default implementation simply passes this message to the next responder.
NSResponder.h
Informs the receiver that the user has moved the mouse with the right button pressed .
- (void)rightMouseDragged:(NSEvent *)theEvent
An object encapsulating information about the mouse-dragged event.
The default implementation simply passes this message to the next responder.
NSResponder.h
Informs the receiver that the user has released the right mouse button.
- (void)rightMouseUp:(NSEvent *)theEvent
An object encapsulating information about the mouse-up event.
The default implementation simply passes this message to the next responder.
NSResponder.h
Implemented by subclasses to scroll the receiver one line down in its scroll view, without changing the selection.
- (void)scrollLineDown:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
– scrollLineUp:
– lineScroll
(NSScrollView)NSResponder.h
Implemented by subclasses to scroll the receiver one line up in its scroll view, without changing the selection.
- (void)scrollLineUp:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
– scrollLineDown:
– lineScroll
(NSScrollView)NSResponder.h
Implemented by subclasses to scroll the receiver one page down in its scroll view, without changing the selection.
- (void)scrollPageDown:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
– pageDown:
– pageUp:
– pageScroll
(NSScrollView)NSResponder.h
Implemented by subclasses to scroll the receiver one page up in its scroll view, without changing the selection.
- (void)scrollPageUp:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
– pageDown:
– pageUp:
– pageScroll
(NSScrollView)NSResponder.h
Informs the receiver that the mouse’s scroll wheel has moved.
- (void)scrollWheel:(NSEvent *)theEvent
An object encapsulating information about the wheel-scrolling event.
The default implementation simply passes this message to the next responder.
NSResponder.h
Implemented by subclasses to select all selectable elements.
- (void)selectAll:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to select all elements in the line or lines containing the selection or insertion point.
- (void)selectLine:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to select all paragraphs containing the selection or insertion point.
- (void)selectParagraph:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to select all items from the insertion point or selection to a previously placed mark, including the selection itself if not empty.
- (void)selectToMark:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Implemented by subclasses to extend the selection to the nearest word boundaries outside it (up to, but not including, word delimiters).
- (void)selectWord:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Sets the receiver’s style to the style specified by interfaceStyle, such as NSMacintoshInterfaceStyle
or NSWindows95InterfaceStyle
.
- (void)setInterfaceStyle:(NSInterfaceStyle)interfaceStyle
An enum
constant identifying an interface style.
setInterfaceStyle:
is an abstract method in NSResponder
, but is overridden in classes such as NSWindow
and NSView
to actually set the interface style. You should almost never need to invoke or override this method, but if you do override it, your version should always invoke the implementation in super
.
NSInterfaceStyle.h
Implemented by subclasses to set a mark at the insertion point or selection, which is used by deleteToMark:
and selectToMark:
.
- (void)setMark:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Sets the receiver’s menu.
- (void)setMenu:(NSMenu *)aMenu
The menu object to set as the receiver's menu.
If the receiver is an NSApplication
object, this method sets the main menu, typically set using setMainMenu:
.
NSResponder.h
Sets the receiver’s next responder.
- (void)setNextResponder:(NSResponder *)aResponder
An object that inherits, directly or indirectly, from NSResponder
.
NSResponder.h
Returns YES
if the specified event should be treated as an ink event, NO
if it should be treated as a mouse event.
- (BOOL)shouldBeTreatedAsInkEvent:(NSEvent *)theEvent
An event object representing the event to be tested.
This method provides the ability to distinguish when a pen-down should start inking versus when a pen-down should be treated as a mouse down event. This allows for a write-anywhere model for pen-based input.
The default implementation in NSApplication
sends the method to the NSWindow
object under the pen. If the window is inactive, this method returns YES
, unless the pen-down is in the window drag region. If the window is active, this method is sent to the NSView
object under the pen.
The default implementation in NSView
returns YES
, and NSControl
overrides and returns NO
. This allows write-anywhere over most NSView
objects, but allows the pen to be used to track in controls and to move windows.
A custom view should override this method to get the correct behavior for a pen-down in the view.
NSResponder.h
Implemented by subclasses to invoke the help system, displaying information relevant to the receiver and its current state.
- (void)showContextHelp:(id)sender
Typically the object that invoked this method.
NSResponder.h
Swaps the mark and the selection or insertion point, so that what was marked is now the selection or insertion point, and what was the insertion point or selection is now the mark.
- (void)swapWithMark:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Informs the receiver that a tablet-point event has occurred.
- (void)tabletPoint:(NSEvent *)theEvent
An object encapsulating information about the tablet-point event.
Tablet events are represented by NSEvent
objects of type NSTabletPoint
. They describe the current state of a transducer (that is, a pointing device) that is in proximity to its tablet, reflecting changes such as location, pressure, tilt, and rotation. See the NSEvent
reference for the methods that allow you to extract this and other information from theEvent. The default implementation of NSResponder
passes the message to the next responder.
NSResponder.h
Informs the receiver that a tablet-proximity event has occurred.
- (void)tabletProximity:(NSEvent *)theEvent
An object encapsulating information about the tablet-point event.
Tablet events are represented by NSEvent
objects of type NSTabletProximity
. Tablet devices generate proximity events when the transducer (pointing device) nears a tablet and when it moves away from a tablet. From an event object of this type you can extract information about the kind of device and its capabilities, as well as the relation of this tablet-proximity event to various tablet-point events; see the NSEvent
reference for details. The default implementation passes the message to the next responder.
NSResponder.h
Transposes the characters to either side of the insertion point and advances the insertion point past both of them. Does nothing to a selected range of text.
- (void)transpose:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Transposes the words to either side of the insertion point and advances the insertion point past both of them. Does nothing to a selected range of text.
- (void)transposeWords:(id)sender
Typically the object that invoked this method.
NSResponder
declares but doesn’t implement this method.
NSResponder.h
Attempts to perform the action indicated method with a specified argument.
- (BOOL)tryToPerform:(SEL)anAction with:(id)anObject
The selector identifying the action method.
The object to use as the sole argument of the action method.
Returns NO
if no responder is found that responds to anAction, YES
otherwise.
If the receiver responds to anAction, it invokes the method with anObject as the argument and returns YES
. If the receiver doesn’t respond, it sends this message to its next responder with the same selector and object.
– doCommandBySelector:
– sendAction:to:from:
(NSApplication)NSResponder.h
Returns the undo manager for this responder.
- (NSUndoManager *)undoManager
NSResponder
’s implementation simply passes this message to the next responder.
NSResponder.h
Implemented by subclasses to make uppercase every letter in the word or words surrounding the insertion point or selection, expanding the selection if necessary.
- (void)uppercaseWord:(id)sender
Typically the object that invoked this method.
If either end of the selection partially covers a word, that entire word is made uppercase. NSResponder
declares but doesn’t implement this method.
NSResponder.h
Overridden by subclasses to determine what services are available.
- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
A string identifying the send type of pasteboard data. May be an empty string (see discussion).
A string identifying the return type of pasteboard data. May be an empty string (see discussion).
If the receiver can place data of sendType on the pasteboard and receive data of returnType, it should return self
; otherwise it should return either [super validRequestorForSendType:returnType:]
or [[self nextResponder] validRequestorForSendType:returnType:]
, which allows an object higher up in the responder chain to have an opportunity to handle the message.
With each event, and for each service in the Services menu, the application object sends this message up the responder chain with the send and return type for the service being checked. This method is therefore invoked many times per event. The default implementation simply forwards this message to the next responder, ultimately returning nil
.
Either sendType or returnType—but not both—may be empty. If sendType is empty, the service doesn’t require input from the application requesting the service. If returnType is empty, the service doesn’t return data.
– registerServicesMenuSendTypes:returnTypes:
(NSApplication
)– writeSelectionToPasteboard:types:
(NSServicesRequests
protocol)– readSelectionFromPasteboard:
(NSServicesRequests
protocol)NSResponder.h
Implemented by subclasses to return a custom version of the supplied error object that is more suitable for presentation in alert sheets and dialogs.
- (NSError *)willPresentError:(NSError *)anError
The error object to be customized.
The customized error object; if you decide not to customize the error presentation, return by sending this message to super
(that is, return [super willPresentError:anError]
).
When overriding this method, you can examine anError and, if its localized description or recovery information is unhelpfully generic, return an error object with more specific localized text. If you do this, always use the domain and error code of the NSError
object to distinguish between errors whose presentation you want to customize and those you do not. Don’t make decisions based on the localized description, recovery suggestion, or recovery options because parsing localized text is problematic.
The default implementation of this method simply returns anError unchanged.
NSResponder.h
Replaces the insertion point or selection with text from the kill buffer.
- (void)yank:(id)sender
Typically the object that invoked this method.
If invoked sequentially, cycles through the kill buffer in reverse order. See “Standard Action Methods for Selecting and Editing” for more information on the kill buffer. NSResponder
declares but doesn’t implement this method.
– deleteToBeginningOfLine:
– deleteToEndOfLine:
– deleteToBeginningOfParagraph:
– deleteToEndOfParagraph:
– deleteToMark:
NSResponder.h
© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-03-05)