• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Creating NSButton in Code does not set controlTint to currentControlTint
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating NSButton in Code does not set controlTint to currentControlTint


  • Subject: Creating NSButton in Code does not set controlTint to currentControlTint
  • From: Peter Teeson <email@hidden>
  • Date: Thu, 26 Dec 2013 12:49:27 -0500

MountainLion 10.8.5, Xcode 5.0.2
My code creates some objects in code rather than using IB.
This creates an NS Button, tests for the currentControlTint and the Cell controlTint.

@interface Document : NSDocument
………
@property NSButton *Cancel;
@property NSButton *Check;
@end

@implementation Document
……………
_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
……………
@end

The documentation in the NSCell Class Reference states:
Designated Initializers
When subclassing NSCell you must implement all of the designated initializers.
Those methods are: init, initWithCoder:, initTextCell:, and initImageCell:.

and later on
Sets the receiver’s control tint.
 - (void)setControlTint:(NSControlTint)controlTint
 Parameters
 controlTint
 An Designated Initializers value that specifies the tint of the receiver.

Changing the instantiation code to this makes no difference:
    _Cancel = [[NSButton alloc]init];
    [_Cancel setFrame:theButtonFrame];
    [_Cancel setNeedsDisplay:YES];

So my questions are:
(0) Is the fact that initWithFrame does not set the currentControlTint a bug (and hence worth a bug report)?
(1) It is not in the list of Designated Initializers - should it be?
(2) Other than sub-classing NSCellInit and NSButton what other code way can I set the controlTint for the Button?

TIA

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


  • Follow-Ups:
    • Re: Creating NSButton in Code does not set controlTint to currentControlTint
      • From: Uli Kusterer <email@hidden>
    • Re: Creating NSButton in Code does not set controlTint to currentControlTint
      • From: Keary Suska <email@hidden>
  • Prev by Date: Customizing UIActivityViewController
  • Next by Date: Re: Creating NSButton in Code does not set controlTint to currentControlTint
  • Previous by thread: Customizing UIActivityViewController
  • Next by thread: Re: Creating NSButton in Code does not set controlTint to currentControlTint
  • Index(es):
    • Date
    • Thread