1{%mainunit appkit.pas}
2{
3        NSResponder.h
4        Application Kit
5        Copyright (c) 1994-2005, Apple Computer, Inc.
6        All rights reserved.
7}
8
9{$ifdef CLASSES}
10{$ifndef NSRESPONDER_PAS_C}
11{$define NSRESPONDER_PAS_C}
12
13//@class NSArray, NSError, NSEvent, NSMenu, NSUndoManager, NSWindow;
14
15  NSResponder = class(NSObject)// <NSCoding>
16  public
17
18{- (NSResponder *)nextResponder;
19- (void)setNextResponder:(NSResponder *)aResponder;
20- (BOOL)tryToPerform:(SEL)anAction with:(id)anObject;
21- (BOOL)performKeyEquivalent:(NSEvent *)theEvent;
22- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType;
23- (void)mouseDown:(NSEvent *)theEvent;
24- (void)rightMouseDown:(NSEvent *)theEvent;
25- (void)otherMouseDown:(NSEvent *)theEvent;
26- (void)mouseUp:(NSEvent *)theEvent;
27- (void)rightMouseUp:(NSEvent *)theEvent;
28- (void)otherMouseUp:(NSEvent *)theEvent;
29- (void)mouseMoved:(NSEvent *)theEvent;
30- (void)mouseDragged:(NSEvent *)theEvent;
31- (void)scrollWheel:(NSEvent *)theEvent;
32- (void)rightMouseDragged:(NSEvent *)theEvent;
33- (void)otherMouseDragged:(NSEvent *)theEvent;
34- (void)mouseEntered:(NSEvent *)theEvent;
35- (void)mouseExited:(NSEvent *)theEvent;
36- (void)keyDown:(NSEvent *)theEvent;
37- (void)keyUp:(NSEvent *)theEvent;
38- (void)flagsChanged:(NSEvent *)theEvent;
39#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
40- (void)tabletPoint:(NSEvent *)theEvent;
41- (void)tabletProximity:(NSEvent *)theEvent;
42#endif
43- (void)noResponderFor:(SEL)eventSelector;
44- (BOOL)acceptsFirstResponder;
45- (BOOL)becomeFirstResponder;
46- (BOOL)resignFirstResponder;
47
48- (void)interpretKeyEvents:(NSArray *)eventArray;
49- (void)flushBufferedKeyEvents;
50
51- (void)setMenu:(NSMenu *)menu;
52- (NSMenu *)menu;
53
54- (void)showContextHelp:(id)sender;
55
56- (void)helpRequested:(NSEvent *)eventPtr;
57
58#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2
59- (BOOL)shouldBeTreatedAsInkEvent:(NSEvent *)theEvent;
60#endif
61@end
62
63@interface NSResponder(NSKeyboardUI)
64- (BOOL)performMnemonic:(NSString *)theString;
65@end
66
67@interface NSResponder (NSStandardKeyBindingMethods)
68
69// This category contains a large number of methods intended for use as key binding commands.  NSResponder does not implement any of them.  NSTextView implements a certain subset of them (see the NSTextView.h header).  Your responder subclasses can implement any that make sense.  You can make up your own as well, but you should use these if the concepts map.  If your view is key and uses key binding and the user types a key sequence which is bound to a command which is not implemented in your class, it is OK, nothing will happen by default.
70
71/************************* Key binding entry-points *************************/
72
73- (void)insertText:(id)insertString;
74    // When key events have been passed off to the key binding mechanism through interpretKeyEvents:, they end up back in the view through either this method or the below doCommand... methods.  insertText: is used to pass through text that was not a command.
75
76- (void)doCommandBySelector:(SEL)aSelector;
77    // Performs the given selector if possible.
78
79/************************* Standard bindable commands *************************/
80
81    /* Selection movement and scrolling */
82
83- (void)moveForward:(id)sender;
84- (void)moveRight:(id)sender;
85- (void)moveBackward:(id)sender;
86- (void)moveLeft:(id)sender;
87- (void)moveUp:(id)sender;
88- (void)moveDown:(id)sender;
89- (void)moveWordForward:(id)sender;
90- (void)moveWordBackward:(id)sender;
91- (void)moveToBeginningOfLine:(id)sender;
92- (void)moveToEndOfLine:(id)sender;
93- (void)moveToBeginningOfParagraph:(id)sender;
94- (void)moveToEndOfParagraph:(id)sender;
95- (void)moveToEndOfDocument:(id)sender;
96- (void)moveToBeginningOfDocument:(id)sender;
97- (void)pageDown:(id)sender;
98- (void)pageUp:(id)sender;
99- (void)centerSelectionInVisibleArea:(id)sender;
100
101- (void)moveBackwardAndModifySelection:(id)sender;
102- (void)moveForwardAndModifySelection:(id)sender;
103- (void)moveWordForwardAndModifySelection:(id)sender;
104- (void)moveWordBackwardAndModifySelection:(id)sender;
105- (void)moveUpAndModifySelection:(id)sender;
106- (void)moveDownAndModifySelection:(id)sender;
107
108#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
109- (void)moveWordRight:(id)sender;
110- (void)moveWordLeft:(id)sender;
111- (void)moveRightAndModifySelection:(id)sender;
112- (void)moveLeftAndModifySelection:(id)sender;
113- (void)moveWordRightAndModifySelection:(id)sender;
114- (void)moveWordLeftAndModifySelection:(id)sender;
115#endif
116
117- (void)scrollPageUp:(id)sender;
118- (void)scrollPageDown:(id)sender;
119- (void)scrollLineUp:(id)sender;
120- (void)scrollLineDown:(id)sender;
121
122    /* Graphical Element transposition */
123
124- (void)transpose:(id)sender;
125- (void)transposeWords:(id)sender;
126
127    /* Selections */
128
129- (void)selectAll:(id)sender;
130- (void)selectParagraph:(id)sender;
131- (void)selectLine:(id)sender;
132- (void)selectWord:(id)sender;
133
134    /* Insertions and Indentations */
135
136- (void)indent:(id)sender;
137- (void)insertTab:(id)sender;
138- (void)insertBacktab:(id)sender;
139- (void)insertNewline:(id)sender;
140- (void)insertParagraphSeparator:(id)sender;
141- (void)insertNewlineIgnoringFieldEditor:(id)sender;
142- (void)insertTabIgnoringFieldEditor:(id)sender;
143#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
144- (void)insertLineBreak:(id)sender;
145- (void)insertContainerBreak:(id)sender;
146#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4 */
147
148    /* Case changes */
149
150- (void)changeCaseOfLetter:(id)sender;
151- (void)uppercaseWord:(id)sender;
152- (void)lowercaseWord:(id)sender;
153- (void)capitalizeWord:(id)sender;
154
155    /* Deletions */
156
157- (void)deleteForward:(id)sender;
158- (void)deleteBackward:(id)sender;
159#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
160- (void)deleteBackwardByDecomposingPreviousCharacter:(id)sender;
161#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 */
162- (void)deleteWordForward:(id)sender;
163- (void)deleteWordBackward:(id)sender;
164- (void)deleteToBeginningOfLine:(id)sender;
165- (void)deleteToEndOfLine:(id)sender;
166- (void)deleteToBeginningOfParagraph:(id)sender;
167- (void)deleteToEndOfParagraph:(id)sender;
168
169- (void)yank:(id)sender;
170
171    /* Completion */
172
173- (void)complete:(id)sender;
174
175    /* Mark/Point manipulation */
176
177- (void)setMark:(id)sender;
178- (void)deleteToMark:(id)sender;
179- (void)selectToMark:(id)sender;
180- (void)swapWithMark:(id)sender;
181
182    /* Cancellation */
183
184#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3
185- (void)cancelOperation:(id)sender;
186#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3 */
187@end
188
189@interface NSResponder(NSUndoSupport)
190- (NSUndoManager *)undoManager;
191@end
192
193#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
194
195@interface NSResponder(NSErrorPresentation)
196
197/* Present an error alert to the user, as a document-modal panel. When the user has dismissed the alert and any recovery possible for the error and chosen by the user has been attempted, send the selected message to the specified delegate. The method selected by didPresentSelector must have the same signature as:
198
199    - (void)didPresentErrorWithRecovery:(BOOL)didRecover contextInfo:(void *)contextInfo;
200
201The default implementation of this method always invokes [self willPresentError:error] to give subclassers an opportunity to customize error presentation. It then forwards the message, passing the customized error, to the next responder or, if there is no next responder, NSApp. NSApplication's override of this method invokes [[NSAlert alertWithError:theErrorToPresent] beginSheetModalForWindow:window modalDelegate:self didEndSelector:selectorForAPrivateMethod contextInfo:privateContextInfo]. When the user has dismissed the alert, the error's recovery attempter is sent an -attemptRecoveryFromError:optionIndex:delegate:didRecoverSelector:contextInfo: message, if the error had recovery options and a recovery delegate.
202
203Errors for which ([[error domain] isEqualToString:NSCocoaErrorDomain] && [error code]==NSUserCancelledError) are a special case,  because they do not actually represent errors and should not be presented as such to the user. NSApplication's override of this method does not present an alert to the user for these kinds of errors. Instead it merely invokes the delegate specifying didRecover==NO.
204
205Between the responder chain in a typical application and various overrides of this method in AppKit classes, objects are given the opportunity to present errors in orders like these:
206
207    For windows owned by documents:
208    view -> superviews -> window -> window controller -> document -> document controller -> application
209
210    For windows that have window controllers but aren't associated with documents:
211    view -> superviews -> window -> window controller -> application
212
213    For windows that have no window controller at all:
214    view -> superviews -> window -> application
215
216You can invoke this method to present error alert sheets. For example, Cocoa's own -[NSDocument saveToURL:ofType:forSaveOperation:delegate:didSaveSelector:contextInfo:] invokes this method when it's just invoked -saveToURL:ofType:forSaveOperation:error: and that method has returned NO.
217
218You probably shouldn't override this method, because you have no way of reliably predicting whether this method vs. -presentError will be invoked for any particular error. You should instead override the -willPresentError: method described below.
219*/
220- (void)presentError:(NSError *)error modalForWindow:(NSWindow *)window delegate:(id)delegate didPresentSelector:(SEL)didPresentSelector contextInfo:(void *)contextInfo;
221
222/* Present an error alert to the user, as an application-modal panel, and return YES if error recovery was done, NO otherwise. This method behaves much like the previous one except it does not return until the user has dismissed the alert and, if the error had recovery options and a recovery delegate, the error's recovery delegate has been sent an -attemptRecoveryFromError:optionIndex: message.
223
224You can invoke this method to present error alert dialog boxes. For example, Cocoa's own [NSDocumentController openDocument:] invokes this method when it's just invoked -openDocumentWithContentsOfURL:display:error: and that method has returned nil.
225
226You probably shouldn't override this method, because you have no way of reliably predicting whether this method vs. -presentError:modalForWindow:delegate:didPresentSelector:contextInfo: will be invoked for any particular error. You should instead override the -willPresentError: method described below.
227*/
228- (BOOL)presentError:(NSError *)error;
229
230/* Given that the receiver is about to present an error (perhaps by just forwarding it to the next responder), return the error that should actually be presented. The default implementation of this method merely returns the passed-in error.
231
232You can override this method to customize the presentation of errors by examining the passed-in error and if, for example, its localized description or recovery information is unsuitably generic, returning a more specific one. When you override this method always check the NSError's domain and code to discriminate between errors whose presentation you want to customize and those you don't. For those you don't just return [super willPresentError:error]. Don't make decisions based on the NSError's localized description, recovery suggestion, or recovery options because it's usually not a good idea to try to parse localized text.
233*/
234- (NSError *)willPresentError:(NSError *)error;
235
236@end
237
238#endif}
239
240  end;
241
242{$endif}
243{$endif}
244
245