Toolbar customization

I’m trying to use a small toolbar in my app (with no icons) but it insists on being full size, I’ve even tried setting the following declare in the open event of the toolbar, but I cannot get a small toolbar.

declare sub setSizeMode lib cocoaLibrary selector "setDisplayMode:" ( toolbarHandle as integer, sizeMode as integer ) setSizeMode( me.handle, 2 )

Anyone have any pointers, I’d rather not have to recreate my toolbar in a different class just to get the small height.

[quote=9766:@Sam Rowlands]I’m trying to use a small toolbar in my app (with no icons) but it insists on being full size, I’ve even tried setting the following declare in the open event of the toolbar, but I cannot get a small toolbar.

declare sub setSizeMode lib cocoaLibrary selector "setDisplayMode:" ( toolbarHandle as integer, sizeMode as integer ) setSizeMode( me.handle, 2 )

Anyone have any pointers, I’d rather not have to recreate my toolbar in a different class just to get the small height.[/quote]

Toolbar.Handle always returns 0. You’ll have to find the window it’s on, get its handle, and the NSToolbar from the NSWindow.

Ah cheers Joe, I never even thought to check that it returns zero, would you like me to file a Feedback case?

There’s already one filed (17116). Despite how it might sound, it’s not a trivial thing to fix.

Well, you could use our CustomNSToolbarMBS class which has an event for controlling allowed modes.
And there you can set mode.

You get the handle of the Cocoa toolbar as mentioned by Joe Ranieri via the window handle:

Declare Function toolbar Lib "AppKit.framework" Selector "toolbar" (NSWindow As Ptr) As Ptr Dim windowPtr As Ptr = Ptr(myWindow.Handle) Dim toolbarPtr As Ptr = toolbar(windowPtr) setSizeMode(toolbarPtr, 2)

Thanks Lukas, that’s very similar to the code I used.