Programmatically create view and handle events
Programmatically create view and handle events
- Subject: Programmatically create view and handle events
- From: Luca Tarozzi <email@hidden>
- Date: Wed, 26 Jan 2011 17:29:03 +0100
Hi all,
I am new to cocoa and objective C.
I am looking for a way to handle events for a NSView created
programmatically (without IB).
Is it possible starting from the following code?
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
// [[NSColor yellowColor] set];
NSView *superView = [window contentView];
// [NSBezierPath fillRect:[superView bounds]];
NSRect frame = NSMakeRect(50, 50, 200, 100);
NSView *myView = [[NSView alloc] initWithFrame:frame];
[superView addSubview:myView];
[[NSColor greenColor] set];
[NSBezierPath fillRect:[myView bounds]];
[myView setTarget:self]
// [myView setNeedsDisplay:YES];
[myView release];
}
Thanks
Luca
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden