NSShadow
-
Folks,
I have an NSControl, in IB i've set a shadow and a color (green). it
has an IBOutlet and is "hooked" up to my controller. When my app is
run, the checkbox has a lovely green shadow. Go baby go....
During runtime I want to change the shadow color - but am failing to
do so. So, to simplify the logic...
In awake from nib I see the control (mCheckbox) is not nil, so I try
to set the shadow color to black :
IBOutlet NSControl *mCheckBox;
/* awakefromnib */
NSShadow *aShadow = [mCheckbox shadow];
[aShadow setShadowColor:[[NSColor blackColor] colorWithAlphaComponent:
1.0]];
[mCheckbox setShadow:aShadow];
No change. No errors. Nothing nil.
Looks like it makes sense to me... but... it does not work, so, I'm
missing something... somewhere... should be obvious.... just not to me.
Been searching docs and sample code bits (have not found an example
of changing a shadow on a control) - trying foolish things - stuck.
This has to be simpler than the two hours spent getting this far.
Thanks!
Gary -
Hi Gary,
Try making a new shadow rather than mutating the one you get from the
view. When you set it back, the view does not realize the shadow has
changed, and so does not update the CoreAnimation layer tree.
Please file a bug for this.
-Ken
On Tue, Nov 18, 2008 at 1:19 AM, M Pulis <toothpic...> wrote:
> Folks,
>
> I have an NSControl, in IB i've set a shadow and a color (green). it has an
> IBOutlet and is "hooked" up to my controller. When my app is run, the
> checkbox has a lovely green shadow. Go baby go....
>
> During runtime I want to change the shadow color - but am failing to do so.
> So, to simplify the logic...
>
> In awake from nib I see the control (mCheckbox) is not nil, so I try to set
> the shadow color to black :
>
> IBOutlet NSControl *mCheckBox;
>
> /* awakefromnib */
> NSShadow *aShadow = [mCheckbox shadow];
> [aShadow setShadowColor:[[NSColor blackColor] colorWithAlphaComponent:1.0]];
> [mCheckbox setShadow:aShadow];
>
> No change. No errors. Nothing nil.
>
> Looks like it makes sense to me... but... it does not work, so, I'm missing
> something... somewhere... should be obvious.... just not to me.
>
> Been searching docs and sample code bits (have not found an example of
> changing a shadow on a control) - trying foolish things - stuck. This has to
> be simpler than the two hours spent getting this far.
>
> Thanks!
>
> Gary
>
-
Thanks, Ken,
Will check it out and file a bug.... should be a cinch to create a
demo for them.
Need a yet another new class: NSMutableShadow :-))
Gary
On Nov 20, 2008, at 12:06 AM, Ken Ferry wrote:
> Hi Gary,
>
> Try making a new shadow rather than mutating the one you get from the
> view. When you set it back, the view does not realize the shadow has
> changed, and so does not update the CoreAnimation layer tree.
>
> Please file a bug for this.
>
> -Ken
>
> On Tue, Nov 18, 2008 at 1:19 AM, M Pulis <toothpic...> wrote:
>> Folks,
>>
>> I have an NSControl, in IB i've set a shadow and a color (green).
>> it has an
>> IBOutlet and is "hooked" up to my controller. When my app is run, the
>> checkbox has a lovely green shadow. Go baby go....
>>
>> During runtime I want to change the shadow color - but am failing
>> to do so.
>> So, to simplify the logic...
>>
>> In awake from nib I see the control (mCheckbox) is not nil, so I
>> try to set
>> the shadow color to black :
>>
>> IBOutlet NSControl *mCheckBox;
>>
>> /* awakefromnib */
>> NSShadow *aShadow = [mCheckbox shadow];
>> [aShadow setShadowColor:[[NSColor blackColor]
>> colorWithAlphaComponent:1.0]];
>> [mCheckbox setShadow:aShadow];
>>
>> No change. No errors. Nothing nil.
>>
>> Looks like it makes sense to me... but... it does not work, so,
>> I'm missing
>> something... somewhere... should be obvious.... just not to me.
>>
>> Been searching docs and sample code bits (have not found an
>> example of
>> changing a shadow on a control) - trying foolish things - stuck.
>> This has to
>> be simpler than the two hours spent getting this far.
>>
>> Thanks!
>>
>> Gary
>>



