NEWBIE: Drawing a custom view inside another custom view
NEWBIE: Drawing a custom view inside another custom view
- Subject: NEWBIE: Drawing a custom view inside another custom view
- From: Jason Gignac <email@hidden>
- Date: Thu, 20 Nov 2003 06:57:40 -0600
Well, I'm taking the advice that was given to me before, to just create
a custom sub class of view for my project (I won't go into all the
details). So I'm experimenting right now with drawing in the custom
view 'on-the fly', inside another custom view, and I can't seem to get
it to work! I figured if I initiated the subview, and then added it as
a subview to the mother view, then set the frame for it, it would show
up. So here was my experimental code for motherview:
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
NSRect r=NSMakeRect(10, 10, 50, 100);
dview = [dview initWithFrame:r];
[self addSubview:dview];
[dview setFrame:r];
[dview setBounds:r];
}
return self;
}
- (void)drawRect:(NSRect)rect {
[[NSColor blackColor] set];
NSRectFill(rect);
[dview setNeedsDisplay:YES];
}
dview is just an instance of my custom DaughterView class, which has no
code in it, except to do a blue NSRectFill in its entire frame. But -
it never draws the blue rectangle! Help! I'm missing something obvious,
aren't I? Sorry for the awkward post, and I know this is probably not
the most efficient way to do this anyway - I'm learning, be gentle ;).
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.