Skip to content

Instantly share code, notes, and snippets.

@chamons
Created December 4, 2014 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chamons/3d563be02f37ba7b5ed5 to your computer and use it in GitHub Desktop.
Save chamons/3d563be02f37ba7b5ed5 to your computer and use it in GitHub Desktop.
//
// ViewController.m
// MouseDownTest
//
// Created by Chris Hamons on 12/4/14.
// Copyright (c) 2014 Chris Hamons. All rights reserved.
//
#import "ViewController.h"
@interface MyView : NSView
@end
@implementation MyView
- (void) mouseDown:(NSEvent *)theEvent {
NSLog (@"Down");
[super mouseDown:theEvent];
}
- (void) drawRect:(NSRect)dirtyRect {
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort];
CGContextSetRGBFillColor (context, 1, 0, 0, 1);
CGContextFillRect(context, dirtyRect);
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
MyView * view = [MyView new];
view.frame = CGRectMake(10, 10, 100, 100);
[[self view] addSubview:view];
// Do any additional setup after loading the view.
}
- (void)setRepresentedObject:(id)representedObject {
[super setRepresentedObject:representedObject];
// Update the view, if already loaded.
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment