A standard toolbar item type.
If you supply an action for an item object then it will be enabled by default. You can override this behaviour by
providing either a willEnable block or a bindEnabled() to enable or disable an item when required.
Core properties
| Property |
Type (default) |
Description |
image |
NSImage |
the image to display on the toolbar item |
Core actions
| Action |
Description |
action |
The block to call when the toolbar item is activated (eg. clicked) |
willEnable |
Supply a callback block to be called to determine the enabled state of the item |
Core bindings
| Binding |
Type (default) |
Description |
bindImage |
DSFImage |
Bind the image for the toolbar item |
DSFToolbar.Item(NSToolbarItem.Identifier("toolbar-watermelon"))
.label("Watermelon")
.image(ProjectAssets.ImageSet.toolbar_watermelon.image)
.willEnable { [weak self] in
self?.isWatermelonEnabled() ?? false
}
.action { _ in
Swift.print("Got grouped watermelon!")
}
Sample Code