create multiple Custom Views
create multiple Custom Views
- Subject: create multiple Custom Views
- From: N!K <email@hidden>
- Date: Tue, 5 Oct 2010 17:23:40 -0700
I know this should be really easy, but I've been unsuccessful finding an explanation or tutorial in Apple's documentation or in Google. A couple terse examples did show up, but I did not understand them or they didn't seem to apply.
In simplest form, I need to put two Custom Views onto the one window in Interface Builder along with two buttons to control them. Each button should cause a new Bezier line to be drawn on its associated window. The buttons are no problem, but controlling the two Custom Views individually is.
Lots of material covers a single Custom View. I have no difficulty creating one and using it, although I do not understand specifically what assigns the Custom View pointer to in -(void)drawRect:(NSRect)rect or –(id)initWithFrame:(NSRect)frameRect. I'm accepting on faith that the system “knows” because there is only one Custom View in the one NSView subclass in these examples.
However, I think I need to know how to assign the arguments when there is more than one Custom View, in order to direct the init and draw to the correct Custom View. When I naively drag a second Custom View and AppController onto the window, make the connections, and attempt to associate the two Custom Views and use two IBOutlets to control them, I fail completely. Maybe I'm barking up the wrong tree, trying to do this with only one subclass of NSView for both Custom Views.
Questions:
Where can I find out how to assign the init and draw arguments to one Custom View or the other? Or is this the wrong approach?
Is one subclass required for each Custom View? This seems cumbersome when there are several Custom Views.
Are IBOutlets for each Custom View the right approach?
Is this the place for lockFocus, to draw on only the correct Custom View?
And most important of all, is there a good example with explanation that I can follow?
Thanks in advance,
Nick_______________________________________________
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