NSScroller in layer backed view

  • I've just started using CoreAnimation for fading views and simple things like that but now I've run across a problem with NSScroller.

    In a view which is layer backed (setWantsLayer is on) I have a NSScrollView with a custom NSScroller subclass which performs drawing in drawRect:. When the root views setWantsLayer is on the drawRect: method of the NSScroller subclass is never called. The docs did say drawRect: will not be invoked in layer backed views but I'm confused because another NSView subclass in the same layer backed view is getting drawRect: invoked.

    Either way, from what I know about CoreAnimation I probably need to make a CALayer to replace the layer which (presumably) NSScroller is using since drawRect: is not being invoked. However, making a new CALayer (setting it to the NSScroller with setLayer) and overriding drawInContext: is not replacing the original NSScroller drawing.

    Does anyone know how I can acheive custom drawing of the NSScroller in the layer backed view?

    Thanks for any ideas you may have.

    Regards,
    Ryan Joseph
    thealchemistguild.com
  • On 3 Apr 2012, at 08:47, Ryan Joseph wrote:

    > I've just started using CoreAnimation for fading views and simple things like that but now I've run across a problem with NSScroller.
    >
    > In a view which is layer backed (setWantsLayer is on) I have a NSScrollView with a custom NSScroller subclass which performs drawing in drawRect:. When the root views setWantsLayer is on the drawRect: method of the NSScroller subclass is never called. The docs did say drawRect: will not be invoked in layer backed views but I'm confused because another NSView subclass in the same layer backed view is getting drawRect: invoked.
    Are you sure that you haven't set any layers explicitly?
    -drawRect should be called on all subviews when -wantsLayer is true.
    When you create a layer hosting view (that is, assign a layer directly to the view) then -drawRect: will not be called.

    Regards

    Jonathan Mitchell
    Mugginsoft LLP
  • Do not override drawRect:! Override the parts drawing methods:

    – drawKnobSlotInRect:highlight:
    – drawKnob

    https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Appl
    icationKit/Classes/NSScroller_Class/Reference/Reference.html


    -raleigh

    On Apr 3, 2012, at 12:47 AM, Ryan Joseph <ryan...> wrote:

    > I've just started using CoreAnimation for fading views and simple things like that but now I've run across a problem with NSScroller.
    >
    > In a view which is layer backed (setWantsLayer is on) I have a NSScrollView with a custom NSScroller subclass which performs drawing in drawRect:. When the root views setWantsLayer is on the drawRect: method of the NSScroller subclass is never called. The docs did say drawRect: will not be invoked in layer backed views but I'm confused because another NSView subclass in the same layer backed view is getting drawRect: invoked.
    >
    > Either way, from what I know about CoreAnimation I probably need to make a CALayer to replace the layer which (presumably) NSScroller is using since drawRect: is not being invoked. However, making a new CALayer (setting it to the NSScroller with setLayer) and overriding drawInContext: is not replacing the original NSScroller drawing.
    >
    > Does anyone know how I can acheive custom drawing of the NSScroller in the layer backed view?
    >
    > Thanks for any ideas you may have.
    >
    > Regards,
    > Ryan Joseph
    > thealchemistguild.com
previous month april 2012 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30            
Go to today