Toolbar

Represents a NSToolbar. You shouldn’t instantiate it directly, alsways instatiate it through Window.createToolbar().

NSToolbar, delegate and XIBs. I don’t know how XCode manages to allow the design of toolbars without using the delegate property of that toolbar. My guess is that they use some kind of private API. To create a functional toolbar, one has to have a toolbar delegate to create NSToolbarItem instance. This is what xibless does. Therefore, consider your toolbar’s delegate slot taken.

Moreover, that delegate has to be allocated and created at some point, but there is no convenient way to pass the reference’s responsibility to the xibless user. Therefore, the instance of the delegate created for the toolbar will be leaked, so will toolbar items.

In most cases, this isn’t a big deal because the window that contains a toolbar is often a window that lives as long as the application. However, if the leak of the toolbar delegate is a problem, what you should do is to take the ownership of the delegate in your own code and release it yourself.

class Toolbar
displayMode

Cocoa constant. Whether the toolbar displays images and text, or just images, or just text. Use with NSToolbarDisplayMode constants.

allowsUserCustomization

Boolean. Whether the user can customize the toolbar.

autosavesConfiguration

Boolean. Whether the toolbar’s state is autosaved/restored.

addItem(identifier, label[, image])
Parameters:
  • identifier – String
  • label – String
  • image – String

Creates a ToolbarItem with the specified arguments, adds it to the toolbar and returns it. Note that to avoid needless verbosity, the final identifier of the item will be the concatenation of the toolbar’s identifier and the argument. So if your toolbar’s identifier is foo and you call additem('bar', 'mylabel'), the item’s identifier will be foobar.

flexibleSpace()
space()
separator()

Return a Cocoa constant representing one of the built-in toolbar items. Use it to populate defaultItems.

class ToolbarItem
identifier

String. The identifier of the item.

label

String. The label of the item.

paletteLabel

String. The label of the item in the configuration palette. Unless you change it, it will be the same value as label

image

String. Name of the image to be used for the item.

view

View. View associated with the item (if set, it replaces the image).

minSize

Size. Minimum size of the view. Unless you change it, will be set to the view’s size.

maxSize

Size. Maximum size of the view. Unless you change it, will be set to the view’s size.

Previous topic

Slider

This Page