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

Re: Standard AppleEvent and MCL Applications

At 12:46 PM 9/27/93 +0900, Tod Casasent wrote:
>Some time ago, I was using MCL2.0p2 to write a commercial LISP application. 
>When I was implementing Apple Events, I discovered that the contents of Chapter
>12 of the "MCL Reference" book have been changed.  This is in reference to an
>application responding to Quit Application, Open Documents and Print Documents
>events and customizing the Open Application response.
>Could anyone out there send me an explanation of this and examples?

This was changed by "MCL 2.0p1.fasl". From its documentation:


Individual patch file: appleevents-patch.lisp
Add 2 methods (open-application-document and print-application-document)
which are called by open-documents-handler and print-documents-handler
to actually do the open or print of a single file.

open-application-document                       [Generic function]
          application path &optional startup

open-application-document                       [Primary method]
          (application application) path &optional startup

Open-application-document is called by the default startup code (which
you get if you do not specify the :TOPLEVEL-FUNCTION keyword to
SAVE-APPLICATION and when MCL receives an Open Document AppleEvent. It
is called with a first argument of *APPLICATION*, a pathname for the
second argument and no third argument (this is a bug in the patch, it
should be called with a third argument of T when called by the startup
code, and no third argument when an Open Document AppleEvent is
received later on).

The method specialized on APPLICATION will edit the file named by PATH
in a Fred window if it is a text file or LOAD it if it is a fasl file.
All other types of files are ignored.

print-application-document                      [Generic function]
           application path &optional startup

print-application-document                      [Primary method]
          (application application) path &optional startup

Same as open-application-document, but is called in response to
a Print Document AppleEvent. The patch does not cause
print-application-document to be called by startup code. Hopefully,
this bug will be fixed by patch 2.

The method specialized on APPLICATION prints the file named by PATH
by opening it in a Fred Window (with ED) and calling WINDOW-HARDCOPY.


(defclass my-application (application) ())

(setq *application* (make-instance 'my-application))

(defmethod open-application-document ((app my-application) path &optional startup)
  (declare (ignore startup))
  (open-my-application-document path))

(defmethod print-application-document ((app my-application) path &optional startup)
  (declare (ignore startup))
  (print-my-application-document path))