[Openmcl-devel] Questions about Cocoa app development]

Didier Verna didier at lrde.epita.fr
Fri Jan 25 23:50:24 PST 2008


       Hi Mikel,

thank you for the detailed answer.

mikel evins <mevins at mac.com> wrote:

> As for interacting with your application, well, you can build a
> Listener into it. Feel free to send suggestions for how you'd like it
> to work. 

  At a first glance, having a window -> listenener menu option
implemented directly by build-application (optionally with an option to
turn it off) would be nice.

Also, I have done a few tests and noticed that if you create a simple
nib file without a window (just a MainMenu), you do get the listener in
your app. Only when you add a window does the listener go away. How's
that implemented ?


>> 2/ How do you execute specific Lisp code when the application starts,
>> both before and after the GUI is setup ?
>>
>
> One Cocoa-flavored way to do it is to create an application delegate  
> and implement the methods applicationWillFinishLaunching: and  
> applicationDidFinishLaunching:. You can implement these in Lisp and  
> have them evaluate arbitrary Lisp forms. Apple documentation of these  
> and other delegate methods is here:

  OK, I've done a test with a menu-only nib file, but I can't get this
to work. Here's my code (trivial, really):

(defvar *test* nil)

(defclass app-delegate (ns:ns-object)
  ()
  (:metaclass ns:+ns-object))

(objc:defmethod (#/test: :void)
    ((self app-delegate) sender)
  (declare (ignore sender))
  (setf *test* 0)
  (format t "Test~%"))

(objc:defmethod (#/applicationWillFinishLaunching: :void)
    ((self app-delegate) notification)
  (declare (ignore notification))
  (setf *test* 1)
  (format t "Will finish launching~%"))

(objc:defmethod (#/applicationDidFinishLaunching: :void)
    ((self app-delegate) notification)
  (declare (ignore notification))
  (setf *test* 2)
  (format t "Did finish launching~%"))

I've made connections to the app-delegate in the nib file (the delegate
field of the Application itself, and the test action from the Help menu
option). However, only the help button seems to work. Am I doing
something wrong ?



Thanks again for your help !

-- 
Resistance is futile. You will be jazzimilated.

Didier Verna, didier at lrde.epita.fr, http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (0)1 44 08 01 85
94276 Le Kremlin-Bicêtre, France   Fax.+33 (0)1 53 14 59 22  didier at xemacs.org




More information about the Openmcl-devel mailing list