|Version 1 (modified by zzkt, 7 years ago) (diff)|
Interface Builder Support
You can create a window or menu by specifying all of its properties directly, or you can use the Apple Interface Builder application to create an object description called a nib file. You can then specify the nib file with the :view-nib-path initarg and the particular description with the :view-nib-name initarg when you create the window or menu object. Once the object is initialized from the nib file, any additional initargs specified in the make-instance are used to override the nib file settings.
When you load a window or menu from a nib file, subview and menu-item objects are created automatically for subviews and menu items. After a subview or menu item is automatically created, the generic function initialize-view-from-nib is called to give you a chance to update its settings (such as event handlers).
(initialize-from-nib window subview) [method]
Called when a window is being created based on a template from a nib file. The default method does nothing.
(initialize-from-nib menu menu-item) [method]
Called when a menu is being created based on a template from a nib file. The default method does nothing.
TODO: (this note applies to carbon, need to figure out what to do for Cocoa): Controls and menu items in nib files will typically have a command id. To associate a handler with the command, you have two options. One is to associate the handler with the item that generates the command, by using set-view-action inside the item's initialize-view-from-nib. The other option is to allow the comand to be sent to whichever view is the user focus at the time, which you do by not setting the item's view-action. The command will then be propagated to the outermost view that has a handler for it. The handler can be established for a view either when it is first created, by using the initarg associated with the command id by define-carbon-command-event, or at any time by calling set-carbon-event-handler.