FROM : Francois-Jean De Brienne
DATE : Sat Feb 23 06:38:33 2008
sure, but I don't really want to subclass calayer (unnecessary) and I
have a feeling I would run into the same problem, no?
On 23-Feb-08, at 12:20 AM, Matt Long wrote:
> You could try creating your own CALayer derived class that overrides
>
> - (void)drawInContext:(CGContextRef)ctx
>
> drawLayer simply allows your delegate to override that same method
> externally.
>
> -Matt
>
>
> On Feb 22, 2008, at 9:52 PM, Francois-Jean De Brienne wrote:
>
>> Hello everyone,
>>
>> I'm a very new cocoa developer (I switched two months ago) but an
>> experienced (15+ years) developer.
>>
>> I'm struggling trying to get a CALayer delegate method,
>> specifically drawLayer being called. I am trying to host the
>> CALayer inside an NSView that would be the delegate for the CALayer.
>>
>> The CALayer is an attribute of my custom NSView called mainLayer.
>>
>> Here is the initWithFrame method for my custom NSView:
>>
>> -(id) initWithFrame: (NSRect) frameRect
>> {
>> self = [super initWithFrame:frameRect];
>>
>> if (self)
>> {
>> mainLayer = [[[CALayer alloc] init] retain];
>>
>> [mainLayer setDelegate:self];
>> [self setLayer:mainLayer];
>> [self setWantsLayer:YES];
>> }
>>
>> return self;
>> }
>>
>> Then, the custom NSView declares a drawLayer method as such (that
>> I'd want to be called from my mainLayer):
>>
>> -(void)drawLayer:(CALayer*) layer inContext:(CGContextRef)ctx
>> {
>> NSLog (@"Entered drawLayer");
>> }
>>
>> Now, whenever I send the setNeedsDisplay message to mainLayer, I
>> assume that drawLayer would be called. It is not.
>>
>> drawLayer is also declared in the .h for the custom NSView (if that
>> makes any difference).
>>
>> If I override and define drawRect for my NSView, I can verify that
>> it does enter that method:
>>
>> - (void)drawRect:(NSRect)rect
>> {
>> NSLog (@"Entered drawRect");
>> }
>>
>>
>> What am I doing wrong?
>> _______________________________________________
>>
>> Cocoa-dev mailing list (<email_removed>)
>>
>> 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:
>> http://lists.apple.com/mailman/options/cocoa-dev/matt.<email_removed>
>>
>> This email sent to matt.<email_removed>
>
DATE : Sat Feb 23 06:38:33 2008
sure, but I don't really want to subclass calayer (unnecessary) and I
have a feeling I would run into the same problem, no?
On 23-Feb-08, at 12:20 AM, Matt Long wrote:
> You could try creating your own CALayer derived class that overrides
>
> - (void)drawInContext:(CGContextRef)ctx
>
> drawLayer simply allows your delegate to override that same method
> externally.
>
> -Matt
>
>
> On Feb 22, 2008, at 9:52 PM, Francois-Jean De Brienne wrote:
>
>> Hello everyone,
>>
>> I'm a very new cocoa developer (I switched two months ago) but an
>> experienced (15+ years) developer.
>>
>> I'm struggling trying to get a CALayer delegate method,
>> specifically drawLayer being called. I am trying to host the
>> CALayer inside an NSView that would be the delegate for the CALayer.
>>
>> The CALayer is an attribute of my custom NSView called mainLayer.
>>
>> Here is the initWithFrame method for my custom NSView:
>>
>> -(id) initWithFrame: (NSRect) frameRect
>> {
>> self = [super initWithFrame:frameRect];
>>
>> if (self)
>> {
>> mainLayer = [[[CALayer alloc] init] retain];
>>
>> [mainLayer setDelegate:self];
>> [self setLayer:mainLayer];
>> [self setWantsLayer:YES];
>> }
>>
>> return self;
>> }
>>
>> Then, the custom NSView declares a drawLayer method as such (that
>> I'd want to be called from my mainLayer):
>>
>> -(void)drawLayer:(CALayer*) layer inContext:(CGContextRef)ctx
>> {
>> NSLog (@"Entered drawLayer");
>> }
>>
>> Now, whenever I send the setNeedsDisplay message to mainLayer, I
>> assume that drawLayer would be called. It is not.
>>
>> drawLayer is also declared in the .h for the custom NSView (if that
>> makes any difference).
>>
>> If I override and define drawRect for my NSView, I can verify that
>> it does enter that method:
>>
>> - (void)drawRect:(NSRect)rect
>> {
>> NSLog (@"Entered drawRect");
>> }
>>
>>
>> What am I doing wrong?
>> _______________________________________________
>>
>> Cocoa-dev mailing list (<email_removed>)
>>
>> 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:
>> http://lists.apple.com/mailman/options/cocoa-dev/matt.<email_removed>
>>
>> This email sent to matt.<email_removed>
>
| Related mails | Author | Date |
|---|---|---|
| Francois-Jean De B… | Feb 23, 05:52 | |
| Matt Long | Feb 23, 06:20 | |
| Francois-Jean De B… | Feb 23, 06:38 | |
| Vinay Prabhu | Feb 23, 06:41 | |
| Francois-Jean De B… | Feb 23, 06:48 | |
| Bob Van Osten | Feb 23, 07:01 | |
| Francois-Jean De B… | Feb 23, 07:21 | |
| Vinay Prabhu | Feb 23, 07:33 | |
| Kyle Sluder | Feb 23, 07:38 | |
| Francois-Jean De B… | Feb 23, 08:02 | |
| Kyle Sluder | Feb 23, 08:17 |






Cocoa mail archive

