Yeah, I need to look at that original message. I’ve been doing iOS stuff for years and so OS X stuff is a bit foreign to me. I only hit the OS X stuff intermittently - i.e. when my team needs some specific UI stuff which is ironic in a way. We’re all iOS developers learning OS X.
So, can you help me understand what the below code does? So I have this class: @interface MiniTabBarButton : NSButton @property(strong) NSTabViewItem *tabViewItem; @end and we create the button: NSImage* iconImage = [(id <MiniTabBarItem>)tabViewItem.identifier icon]; [iconImage setTemplate:YES]; newButton.image = iconImage; So with that in mind, remember I don’t even really know what NSButton provides (again, I understand UIButtons really well - and I do have some understanding of NSButton custom drawing to some degree as I did write a subclass for the checkbox style: @interface CalendarFilterCheckbox : NSButtonCell BUT, in this case I’m just trying to get the glow on selected images, so when I look at the code below all I see is that we’re getting the bitmap and drawing it. I’m not understanding how that gets a glow. Sorry for being dense, but I do learn quickly. I just am like a blind man at first. > On Nov 4, 2014, at 12:48 PM, Lee Ann Rucker <lruc...@vmware.com> wrote: > > If you want the same blue highlight that NSButton applies to template images, > you can get the NSButtonCell to draw it into a graphics context and get an > image that way - I answered this when you asked about buttons specifically > back in June. (My bug requesting an NSImage method to do that is still open > and presumably unloved) Once you've got your buttonCell configured, do this: > > > NSRect bounds = NSZeroRect; > bounds.size = [template size]; > > NSBitmapImageRep *bmpImageRep = > [NSBitmapImageRep imageRepWithSize:bounds.size scale:scale]; // Utility > wrapper around imageRepWith32bitBuffer > > [NSGraphicsContext saveGraphicsState]; > NSGraphicsContext *bitmapContext = > [NSGraphicsContext graphicsContextWithBitmapImageRep:bmpImageRep]; > [NSGraphicsContext setCurrentContext:bitmapContext]; > > [buttonCell drawImage:template withFrame:bounds inView:nil]; > > [NSGraphicsContext restoreGraphicsState]; > return bmpImageRep; > > > On Nov 4, 2014, at 10:41 AM, Alex Kac <a...@webis.net> wrote: > >> I have an NSImage that looks like in a mini-toolbar - kind of like Xcode. >> >> Now of course I can just create a hand-drawn selected version, but I like >> doing things like that in code. So I’d like to have code that takes the >> NSImage and makes it glow like Xcode here: >> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.dropbox.com_s_by642iw7xosnki7_Screenshot-25202014-2D11-2D04-252011.40.18.png-3Fdl-3D0&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=ie7S-J__EKnfyVOBV7-jV2rZ--p47O6vkyTklpDM3h4&m=lUNK2PEwQXtoqjBGMWU6Y3iSwSvLFO0mx-2wI6kiSNg&s=PSrnj94BQRWKM8dFv5gi7Tz3a3NH1_5gmiUvJHsFfP4&e= >> >> >> I’ve Googled this and I see a bunch of stuff, that I can’t get working at >> all. Most articles were for iOS and some repsonders even said “if I was >> using an NSImage, this would be easy - but for iOS you do…”. >> >> So… can anyone point me to the right place? >> >> _______________________________________________ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> 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/v2/url?u=https-3A__lists.apple.com_mailman_options_cocoa-2Ddev_lrucker-2540vmware.com&d=AAIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=ie7S-J__EKnfyVOBV7-jV2rZ--p47O6vkyTklpDM3h4&m=lUNK2PEwQXtoqjBGMWU6Y3iSwSvLFO0mx-2wI6kiSNg&s=QsN7f2Wy2w3J4nIWtViq9WfFRo-Fwf46hQqveR8coB0&e= >> >> >> This email sent to lruc...@vmware.com > Alex Kac - President and Founder Web Information Solutions, Inc. "To educate a person in mind and not in morals is to educate a menace to society." -- Theodore Roosevelt _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com