• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Programmatically create view and handle events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Programmatically create view and handle events
      • From: Uli Kusterer <email@hidden>
    • Re: Programmatically create view and handle events
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Undo with NSArrayController
  • Next by Date: Re: Programmatically create view and handle events
  • Previous by thread: Re: Undo with NSArrayController
  • Next by thread: Re: Programmatically create view and handle events
  • Index(es):
    • Date
    • Thread