default-init-function

Function

Package: common-graphics

Arguments: nil

default-init-function is the default on-initialization function for a project. It creates and displays the running window for the main form of the project, and then returns that window so that the application will exit when the main window is closed.

Below is the complete code for this function, which an application may model after if it needs to use a custom on-initialization function.

(defun default-init-function ()
  (let* ((main-module (main-module (current-project)))
         window)
    
    ;; This default on-initialization function expects the
    ;; project to have a main form to run.  For a project
    ;; that uses no windows at all, you would need to substitute 
    ;; a different on-initialization function.
    (unless main-module
      (error "The project has no main form to run.  Either add a form ~
                 to the project or give the project a different ~
                 on-initialization function."))
    
    ;; Call the main form module's maker-function to create its window.
    (setq window (funcall (maker-function main-module) 
                          
                          ;; Run the main form on the screen (rather than in 
                          ;; the IDE on the development-main-window where
                          ;; individual forms are run) to emulate a completely
                          ;; independent standalone application.
                          ;; (The preferred initarg is now :owner, but
                          ;; :parent also works with maker-functions
                          ;; that were generated in pre-6.0 versions.)
                          :parent (screen *system*))) 
    
    ;; Cache the main window so that its finder function will
    ;; find it later.
    (add-application-window window)
    
    ;; Select the window if needed so that the end user sees it.
    ;; A custom on-initialization function might want to customize
    ;; the window contents in some way before revealing it here.
    (when (and window
               (eq (state window) :shrunk))
      (select-window window))
    
    ;; Return the main window of the application, to tell the application
    ;; to exit whenever this window becomes closed.
    window))

Common Graphics and IDE documentation is described in About Common Graphics and IDE documentation in cgide.htm.

The documentation is described in introduction.htm and the index is in index.htm.

Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved.

Created 2000.10.5.