Re: Drawing into myView
Re: Drawing into myView
- Subject: Re: Drawing into myView
- From: Gregory Weston <email@hidden>
- Date: Thu, 17 Dec 2009 10:12:29 -0500
>I have a subclass of NSView and I want to draw into it after I retrieve an Image in an NSImageView.
>
>I'm trying to set 2 instance variables in the drawRect block of code...
>
>@property(readwrite) NSRect tRect;
>@property (retain, readwrite) NSGraphicsContext*savedContext;
>_______________________________________________
>
>- (void)drawRect:(NSRect)rect
>{
>[selfsetSavedContext:[NSGraphicsContext currentContext]];
>[selfsetTRect:rect];
>}
>
>...and then in a block of code called when the NSImageView has an image dragged into it,
>I try to draw a black background into the view. Nothing is drawn and I don't seem to have any context.
The normal practice, and by far the easiest, is to draw into your view from within drawRect. At that point everything is set up correctly for you. If at some point you need the view to be drawn you signal that need with a message, rather than just drawing then and there.
G
_______________________________________________
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