All Manuals > CAPI User Guide and Reference Manual > 21 CAPI Reference Entries




The class supporting application menus and message processing for a Cocoa application.







A function or nil.


nil, a menu, or the name of a slot containing a menu in the application interface.


nil, a menu, or a function designator.




The class cocoa-default-application-interface supports the application menu, application messages and other functionality for a Cocoa application.

All Cocoa applications in LispWorks for Macintosh have an application interface, which is a hidden interface that provides the following:

  1. The application menu (the leftmost menu in the menu bar, named after the application). See application-menu below.
  2. The menu bar items that are displayed when no other interfaces are on the screen. See menu-bar-items in interface and menu-bar in define-interface.
  3. An optional Dock context menu. See dock-menu below.
  4. Optional application message processing. See message-callback below.
  5. Control over the lifecycle and display-state of the application as a whole.

If you wish to override the defaults, then you should first define a subclass of cocoa-default-application-interface with your changes. Then set a single instance of this subclass as the application interface by calling set-application-interface before any CAPI functions that make the screen object (such as convert-to-screen and display).

Do not call display with a subclass of cocoa-default-application-interface - the application interface does not have a window on the screen and should be created in addition to the visible interfaces in your application.

When non-nil, message-callback should be a function with signature

interface message &rest args

message-callback will be called for various application messages. The interface argument will be the application interface and the message argument will be a keyword. The message argument will be one of the following:


This message is invoked when the user double-clicks on a document associated with the application or drags a document into the application icon. The args contain the name of the file to open.


This message is invoked just after the user has started the application and all other initialization has been done (including any :open-file message if applicable). You can use it to open a default document for example. There are no args .

application-menu controls the application's main menu. If this is nil, then a minimal application menu will be made using the title of the application interface, otherwise it should be a menu containing the usual items or the name of a slot containing such a menu in the application interface. Note that the Quit item in the application-menu needs to call destroy on the interface, rather than call lw:quit.

dock-menu provides a menu for use by the Mac OS X Dock icon. If the value is nil (the default), then the standard menu is used. If dock-menu is a function designator, it is called with the application interface as its argument when the menu is popped up and should return a menu. Otherwise dock-menu should be a menu, which is used directly. The Dock will add the standard items such as Quit to the end of the menu you supply.

interface initargs are interpreted as follows:

All of these callbacks execute in the thread that runs the Cocoa event loop, so they can call CAPI and GP functions.

The application interface also allows you to control aspects of the application. In particular:

The display-state value can one of:


Show the application and activate it


Show the application again without activating it




Hide Others


Show All


cocoa-default-application-interface is implemented only in LispWorks for Macintosh with the Cocoa IDE.

(example-edit-file "capi/applications/cocoa-application") (example-edit-file "capi/applications/cocoa-application-single-window") (example-edit-file "delivery/macos/multiple-window-application") (example-edit-file "delivery/macos/single-window-application")
See also

Special kinds of windows

CAPI User Guide and Reference Manual (Windows version) - 25 Feb 2015