[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Apple events in toplevel loops



Writing an application (without a Listener) in MCL requires a new toplevel
loop. I tried the following (adapted from the Binhex application).

(defun application-toplevel ()
  (catch-cancel (event-dispatch t)))

(defun application-toplevel-startup ()
  (%set-toplevel #'application-toplevel)
  (let ((finder-parameters (finder-parameters)))
    (when (eq (car finder-parameters) ':open)
      (dolist (file (cdr finder-parameters))
        (when (eq (mac-file-type file)
                  ':text)
          (make-instance 'fred-window 
            :filename file))))))

The application is saved with:

(save-application "Application"
                  :toplevel-function #'application-toplevel-startup
                  :creator <application-file-creator>
                  :resources <resources>
                  :excise-compiler t)

Everything works fine, even resources (icons etc.) are handled correctly :-)
However, my simple toplevel loop does not care for apple events like |:odoc|.
This is necessary to handle open document events (e.g., via double clicking
the mouse) when the application is already running.

The documentation (page 413) says that MCL does its own dispatching. 
"Lisp takes care of both dispatching and run-time error checking."
These events are indeed handled when MCL's native toplevel-loop is 
installed. However, I cannot use #'toplevel-loop because a listener is
created when it is installed.
Unfortunately, the code for this function is not available.
Can someone give me a hint how the handler for apple events can be kept alive
in an application without a Listener? 

Ralf