According to rdar://9643033, which I filed 3 years ago, the bezelStyle has to 
be NSTexturedRoundedBezelStyle, and it'll work in 10.6 if bordered is NO, but 
10.7 needs a border. I don't know if the bordered part is still required; I 
came up with a workaround to get just the image in the style I need- create a 
button cell like so:

   NSButtonCell *buttonCell =
      [[[NSButtonCell alloc] initImageCell:template] autorelease];
   [buttonCell setBordered:YES];
   [buttonCell setBezelStyle:NSTexturedRoundedBezelStyle];
   [buttonCell setButtonType:NSToggleButton];
   [buttonCell setShowsStateBy:NSContentsCellMask];
   [buttonCell setHighlightsBy:NSCellLightsByContents];

and then set up a graphics context and call the button cell's drawImage method 
to get just the image I want.

I also asked for a way to generate the 3 different template effects in code; 
mine was closed as a dup of still-open rdar://8067825

On Jun 24, 2014, at 3:31 PM, Alex Kac wrote:

> I’m sure I’m missing something simple. Reading the docs, reading some 
> stack-overflow comments, and a few posts on this list from years ago, it 
> seems like I am missing something.
> 
> I have an NSButton with an image. I’d like to have the button look etched 
> when unselected - and tinted blue when selected just like the Xcode 
> mini-tabbar here:
> https://urldefense.proofpoint.com/v1/url?u=https://www.dropbox.com/s/b1f9kxe5ww25ep7/Screenshot%25202014-06-24%252016.24.55.png&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=yJFJhaNnTZDfFSSz1U9TSNMmxGyib3KjZGuKfIhHLxA%3D%0A&m=sxUWtCjh%2B4ewI1f%2BoeXy%2FOk2WBpiUPxoSsyDWjezd6g%3D%0A&s=3173ad0288269cdbf9973105ed8562ea7174d259743d1fea1e4f7ac03804c2bb
> 
> I’m doing this in code, not in IB. I’m using an NSButton subclass:
>                       [self setButtonType: NSToggleButton];
>               [self setBordered: NO];
>               [self setTitle: @""];
>               [self.cell setImageScaling: NSImageScaleProportionallyDown];
>               self.bezelStyle = NSShadowlessSquareBezelStyle;
>               self.focusRingType = NSFocusRingTypeNone;
> 
> 
> And on the image, we’re setting the setTemplate:YES property on it. 
>       [iconImage setTemplate:YES];
> 
> According to several posts on this list, a bezel-less NSButton that’s a 
> toggle button, should give me what I’m looking for, but its not. The obvious 
> other option is to just create an alternate image…which I’m not against, but 
> it just seems like it would be better to use a built-in system if one exists 
> - or does one?
> 
> _______________________________________________
> 
> Cocoa-dev mailing list ([email protected])
> 
> 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:
> https://urldefense.proofpoint.com/v1/url?u=https://lists.apple.com/mailman/options/cocoa-dev/lrucker%2540vmware.com&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=yJFJhaNnTZDfFSSz1U9TSNMmxGyib3KjZGuKfIhHLxA%3D%0A&m=sxUWtCjh%2B4ewI1f%2BoeXy%2FOk2WBpiUPxoSsyDWjezd6g%3D%0A&s=fd77d59caaeb325d5592663d322cb491f3d1d051b38e1743accbfc462ca0ed4d
> 
> This email sent to [email protected]

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to