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

Michael Minerva minerva at agentsheets.com
Tue Jun 22 12:25:53 PDT 2010


I am trying to build an application that will immediately pop up a  
window.  I have attempted to do this by setting the :toplevel-function  
to be a call to a simple function that displays a basic cocoa alert.   
It seems that my function is being called too early because the  
application always fails to start properly, and repeatedly gives  
errors like this in the console:

6/22/10 1:10:04 PM [0x0-0xca0ca].com.clozure.Clozure CL-x8632[36028] >  
Error: There is no applicable method for the generic function:
6/22/10 1:10:04 PM [0x0-0xca0ca].com.clozure.Clozure CL-x8632[36028]  
 >          #<STANDARD-GENERIC-FUNCTION CCL::UI-OBJECT-DO-OPERATION  
#x82FE076>
6/22/10 1:10:04 PM [0x0-0xca0ca].com.clozure.Clozure CL-x8632[36028]  
 >        when called with arguments:
6/22/10 1:10:04 PM [0x0-0xca0ca].com.clozure.Clozure CL-x8632[36028]  
 >          (#<A Dead Mac Pointer> :BREAK-OPTIONS-STRING T)

If I do not set the :toplevel-function the application is built  
without any problems and starts up fine.

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)

(defun MAIN-APPLICATION-FUNCTION ()
   (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? 
  



More information about the Openmcl-devel mailing list