-
Notifications
You must be signed in to change notification settings - Fork 3
/
PARViewController.h
48 lines (31 loc) · 1.94 KB
/
PARViewController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// PARViewController
// Author: Charles Parnot
// Licensed under the terms of the BSD License, as specified in the file 'LICENSE-BSD.txt' included with this distribution
#import <Cocoa/Cocoa.h>
/*
NSViewController base subclass that ensures automatic insertion into the responder chain
USAGE
use as the base subclass, and don't worry about the respnder chain anymore: the view controller is guaranteed to be automatically inserted between the controlled NSView and the next responder that it would normally have in the absence of the view controller
----------------------------------------------------------------------
before: responder X --> view --> Responder Y
----------------------------------------------------------------------
after: responder X --> view --> view controller --> Responder Y
----------------------------------------------------------------------
NOTES
- The view will not be in the responder chain unless it overrides `acceptsFirstResponder` to return YES
and the controller will not be in the responder chain if the view is not in the responder chain.
see: http://katidev.com/blog/2008/07/24/simple-nsviewcontroller-sample-projects/
- The view will still end up in the responder chain if one of the subviews responds YES to `acceptsFirstResponder`, for example if it contains an NSTableView
*/
@class PARObjectObserver;
@interface PARViewController : NSViewController {
PARObjectObserver *nextResponderObserver;
}
// default implementation commits editing of current field editor if the window is key and if a field editor is up
// subclasses can override this method to perform other actions
- (IBAction)endEditing:(id)sender;
@end
// if a subclass implements this optional method, PARViewController will automatically add an observer to the view frame, and the method will be called when the frame is changed
@interface PARViewController (PARViewControllerFrameObserver)
- (void)viewFrameDidChange;
@end