Question

Why is this happening:

As you can see, in the "Allowed Toolbar Items" the image looks fine for the "PHP" toolbar item, and when its actually in the toolbar, it scales weirdly.

Thanks

Was it helpful?

Solution

Found this in the documentation:

The displayed resolution of an image item is dependent on the sizeMode of the toolbar. You should provide image representations specific to the default, regular and small size modes in a single image that supports multiple image representations such as icns or tiff. The appropriate image representation is automatically displayed for the toolbar's current sizeMode. If an appropriate representation is not available, the toolbar scales the representation to the appropriate size for the current mode, at a cost in performance and appearance. Images that are not square are scaled to fit. An image item’s image is also scaled down and used in the image item’s overflow menu item. (Emphasis added)

This seems you might want to try fiddling with the NSToolbarItem's minSize and maxSize properties.

OTHER TIPS

I found it easier to drag an instance of "Image Well" (NSImageView) into the Toolbar. This allows setting appropriate dimensions (just add a minimum and maximum size and you can then set the desired scaling).

It is basically the same as dragging an instance of NSToolbarItem: it just automatically inserts a configurable NSImageView into a new NSToolbarItem. So you can wire it to your Target/Actions as usual.

Tipp: you can also drag NSSegmentedControls and other NSControls into the toolbar :-)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top