All Manuals > CAPI User Guide and Reference Manual

9 Adding Toolbars

You can add a toolbar for an interface using the interface initarg :toolbar-items. This creates a toolbar which is automatically positioned correctly in the window, which the user can customize, and which has platform-standard behavior such as folding on Cocoa. Such a toolbar is referred to as an interface toolbar.

You can also create toolbars using the toolbar class explicitly, and arrange them using layouts in the same way as other elements. This approach is used to implement buttons on a text-input-pane as seen in various tools in the LispWorks IDE such as the Class Browser, but you should note that it has some disadvantages. For more information see 9.9 Non-standard toolbars.

Toolbar buttons typically have images. The examples in this chapter use three standard image identifiers. To run the example code that follows, first evaluate this form:

(setq file-images (list :std-file-new

You also should define these callback functions before attempting any of the examples in this chapter:

(defun test-callback (data interface)
  (display-message "Data ~S in interface ~S" 
                   data interface))
(defun print-callback (data interface)
  (declare (ignore data interface)) 
  (display-message "Print Something"))
(defun hello (data interface)
  (declare (ignore data interface))
  (display-message "Hello World"))

9.1 Creating a toolbar button

9.2 Creating a toolbar with several buttons

9.3 Specifying the image for a toolbar button

9.4 Specifying toolbar callbacks

9.5 Specifying tooltips for toolbar buttons

9.6 Modifying toolbars

9.7 Advanced toolbar features

9.8 Disabling toolbar items

9.9 Non-standard toolbars

CAPI User Guide and Reference Manual (Macintosh version) - 01 Dec 2021 19:31:21