[Openmcl-devel] Building an application that will immediately bring up a window

R. Matthew Emerson rme at clozure.com
Tue Jun 22 20:04:46 PDT 2010

On Jun 22, 2010, at 3:25 PM, Michael Minerva wrote:

> Here is the simple code I am using to try and build my application.   
> Keep in mind that I executed this code inside a version of ccl that  
> was built with a call to (require 'cocoa) and the dialog pops up fine  
> with a simple call to (main-application-function):
> (in-package :ccl)
>   (let ((Alert (#/init (#/alloc ns:ns-alert))))
>     (#/setMessageText: Alert #@"Hello World, I am a CCL applicaiton")
>     (#/addButtonWithTitle: Alert #@"Yes")
>     (#/addButtonWithTitle: Alert #@"No")
>     (#/addButtonWithTitle: Alert #@"Cancel")
>     (case (#/runModal Alert)
>       (#.#$NSAlertFirstButtonReturn t)
>       (#.#$NSAlertSecondButtonReturn nil)
>       (#.#$NSAlertThirdButtonReturn (throw :cancel nil)))))
> (defun BUILD-ALERT-APP ()
>   (require :build-application)
>   (ccl::build-application
>    :name "alert-app"
>    :directory (format nil "~ADesktop/alert/" (user-homedir-pathname))
>    :toplevel-function 'main-application-function
>    ))
> (build-alert-app)
> Is there a way for my method to be called when all of ccl's  
> initialization is complete? 

The usual way for a Cocoa application to know when everything is all set up is to implement the method applicationWillFinishLaunching or applicationDidFinishLaunching in the application delegate object.

The IDE itself is a Cocoa application.  ccl:cocoa-ide;app-delegate.lisp is where the IDE implements these methods.  Apart from loading the file home:ccl-ide-init, they don't really expose a way to run user-supplied functions.  (This is probably a shortcoming of some sort; I'm not sure what the right answer is.)

You could modify those methods to call your function (or functions).

Mikel wrote a tutorial based on Apple's currency converter example.  It's in the examples directory, and also at http://trac.clozure.com/ccl/wiki/AppleCurrencyConverter.  It totally hides all IDE functionality, though.

More information about the Openmcl-devel mailing list