Re: Creating NSButton in Code does not set controlTint to currentControlTint
Re: Creating NSButton in Code does not set controlTint to currentControlTint
- Subject: Re: Creating NSButton in Code does not set controlTint to currentControlTint
- From: Peter Teeson <email@hidden>
- Date: Thu, 26 Dec 2013 21:49:01 -0500
On 2013-12-26, at 6:44 PM, Quincey Morris <email@hidden> wrote:
> On Dec 26, 2013, at 09:49 , Peter Teeson <email@hidden> wrote:
>> Sets the receiver’s control tint.
>> - (void)setControlTint:(NSControlTint)controlTint
>> Parameters
>> controlTint
>> An Designated Initializers value that specifies the tint of the receiver.
> This looks like a documentation editing error. There’s no such thing as a “designated initializers value”. Forget about designated initializers.
Thanks Quincy that's pretty interesting. What should I say if I'm going to file a bug report?
> On Dec 26, 2013, at 15:08 , Peter Teeson <email@hidden> wrote:
>> Simply put. all I wish to do is instantiate an NSButton in code and have it present the Aqua colour when pressed and not the Graphite.
>
> So you showed this code:
>> _Cancel= [[NSButton alloc]initWithFrame:theButtonFrame];
>>
>> NSString *tintImageName;
>> if ([NSColor currentControlTint] == NSGraphiteControlTint)
>> tintImageName=@"GraphiteImage";
>> else
>> tintImageName=@"AquaImage"; // This is the currentControlTint
>>
>> NSString *cellTintText;
>> NSControlTint cellTint = [_Cancel.cell controlTint];
>> if ( cellTint == NSBlueControlTint)
>> cellTintText = @"AquaTint";
>> else
>> cellTintText = @"GraphiteTint"; // This is the cell controlTInt
>
> but you forget to say what (if anything) goes wrong with *this* code. If you’re trying to force the button to aqua, there should be a ‘setControlTint: NSBlueControlTint’ and no ‘if’s, shouldn’t there?
I added the code (except for the original instantiation) so that I can debug and see the values of things to try and understand what's happening.
The rest of the initialization code is as follows:
[_Cancel setTitle:@"Cancel"];
[_Cancel setButtonType:NSToggleButton];
[_Cancel setState:NSOffState];
[_Cancel setBordered:YES];
[_Cancel setBezelStyle:NSShadowlessSquareBezelStyle];
[_Cancel.cell setControlTint:NSBlueControlTint];
[theContentView addSubview:_Cancel];
Note the above statement which appears to be nil potent because I still get the Graphite colour when I press the button.
> Incidentally, I see in the OS X 10.1 release notes that there wasn’t originally a separate value for graphite. That’s not true any more. This fact may imply that the default behavior when creating controls isn’t especially logical, for compatibility reasons. Explicitly setting the desired tint may be the correct thing to do. I dunno.
I understand what you are saying. As you can see I was trying to set it but assumed I was in error based on the documentation. (My custom is to point the finger at myself and I'm usually right ;}
IOW I would have to subclass NSCell and implement the designated initializers.
Any other thoughts?
respect…
Peter
_______________________________________________
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