OSX ToolbarItem caption color

Hi, Does anyone know in declares how to change the caption of a toolitem on the toolbar?

I’m not even sure that’s possible in objc/swift without subclassing NSToolbarItem.

And can I do this from Xojo?

It doesn’t look like it’s possible. I think you may have to fake it.

Have you seen another application doing what you want?

isn’t the caption just the label of the tool item?

If you like advanced toolbar things on Mac, you should check our MBS Plugins. We have a lot of classes there.

see
http://www.monkeybreadsoftware.net/pluginpart-nstoolbar.shtml

[quote=155759:@Sam Rowlands]It doesn’t look like it’s possible. I think you may have to fake it.

Have you seen another application doing what you want?[/quote]

No, i’ve not seen it but I’ve got the window color and the toolbar color dark as I want it but the caption looks too dark so I need it white.

I see, I think you’re going to have to fake it, which is not difficult, just a PITA.

Could you post a screenshot (or you can PM me if you’d rather keep your GUI private), then I can take a look and maybe offer an alternative suggestion?

See the tool item caption

You’re going to have to fake a white control. There’s two ways I can think how to do it.

#1 Create an entire custom toolbar with a canvas.
#2 Embed the caption into the graphic, and use a declare to remove the labels from the toolbar.

I know this is not quite what you’re looking for…

It’s a segmented control with ‘template’ images and a different style applied to it, so that it’s part of the dark background, but also stands out.

[quote=155972:@Sam Rowlands]I know this is not quite what you’re looking for…

It’s a segmented control with ‘template’ images and a different style applied to it, so that it’s part of the dark background, but also stands out.[/quote]
sam, how is the style applied to the segmented control?

This may be my simplest option.

I do it with code, in the open event. The reason being is that with Yosemite, Apple shot every single visual style except the default.

if appKitVersionNumber < appKitVersionNumber10_10 then tbShareButton.MacControlStyle = Uint32( pushButton.buttonFrameStyle.RoundedTextured ) End if

Somewhere on this forum you should be able to find my code for digging out the OS version. Otherwise you can test by seeing if the NSVisualEffectView class exists.

Declare Function NSClassFromString Lib "Cocoa" ( ClassName as CFStringRef ) As Ptr if NSClassFromString( "NSVisualEffectView" ) = nil then // --- 10.9 or older end if

I used the Retina kit to set the Segmented Control icons, and the two icons here are system icons.

Mike, how did you make that black window, especially the part around the traffic lights buttons??
Did you use declares?

Yes - I downloaded an example project made by @Axel Schneider but his link appears to be broken now. I think I still have a barebones template for it so I will post you a link later

Would really appreciate it - thanks Mike.

styleMask is your friend :slight_smile:

Window open

Const NSHUDWindowMask = 8192 me.styleMask = me.styleMask + NSHUDWindowMask

Add the following to a module.

Function styleMask(Extends w as Window) As integer #if TargetCocoa then declare function mStyleMask lib "Cocoa" selector "styleMask" ( ref as integer ) as integer Return mStyleMask( w.handle ) #endif End Function

Sub styleMask(extends w as Window, Assigns value as integer) #if TargetCocoa then declare sub mSetStyleMask lib "Cocoa" selector "setStyleMask:" ( Ref as integer, inValue as integer ) mSetStyleMask( w.handle, value ) #endif End Sub

Thanks Sam - I will try using that.
Do you know if that also changes the toolbar button caption color to white, which Mike was talking about; or is this declare only really suitable for apps without toolbars?

Thanks for providing that declare anyway :slight_smile:

Making the window black and translucent is only a tiny smidgen of the solution, you need to make your own controls to stand out.

One advantage of Yosemite is that the controls are so white they actually work on this window!

Sam,
when I use your code above - my app still compiles and runs - but there is no change??

Are you sure 8192 is the correct number?
Thanks.