Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)mouseDown:(NSEvent *)theEvent {
- NSLog(@"mouse down");
- }
- - (IBAction)doStuff:(id)sender {
- // do stuff here
- }
- @interface ClickerView : NSControl {
- IBOutlet BoothController *controller;
- }
- @end
- - (void)mouseDown:(NSEvent *)theEvent {
- NSLog(@"mouse down");
- [controller start:self];
- }
- @protocol MyViewDelegate
- - (void)doStuff:(NSEvent *)event;
- @end
- @interface MyViewController: NSViewController <MyViewDelegate> {
- // your other ivars etc would go here
- }
- @end
- - (void)doStuff:(NSEvent *)event
- {
- NSLog(@"Do stuff delegate was called");
- }
- @interface MyView: NSView
- @property (readwrite, weak) id<MyViewDelegate> delegate;
- @end
- - (void)mouseDown:(NSEvent *)event
- {
- // Do whatever you need to do
- // Check that the delegate has been set, and this it implements the doStuff: message
- if (delegate && [delegate respondsToSelector:@selector(doStuff:)]) {
- [delegate doStuff:event];
- }
- }
- ...
- MyView *view = [viewController view];
- [view setDelegate:viewController];
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement