[Openmcl-devel] how to show NSAlert on Lisp startup
ralex at cs.colorado.edu
Wed Sep 14 16:47:43 CDT 2011
We have a need to show some NSAlerts at the start of running a CCL-based app on Mac/PC using Cocoa/Cocotron. So far we have not found any permutation that works of *restore-lisp-functions* and :toplevel-function (initarg to build-application) on PCs or Macs.
The code below will not run the login function but not bring up the modal NSAlert on a Mac and crash on a PC. A variation using (ccl::build-application :name "Crasher" :toplevel-function 'login)
does even worse. I am not completely surprised and assume that its just too early in the game of the Cocoa app launch. The main thread may not be running or just not be ready. We did try to call our function from #/applicationDidFinishLaunching which is called but that does not work either.
Is there or how would one create a *Cocoa-Startup-Functions* capable to run modal NSAlerts on CCL Mac and PC?
Any suggestions would be appreciated.
(defun NATIVE-STRING (String) "
Return a native string"
(#/autorelease (ccl::%make-nsstring String)))
(defmethod STANDARD-ALERT-DIALOG ((Message string) &key
(let ((Alert (#/init (#/alloc ns:ns-alert))))
(#/setMessageText: Alert (native-string Message))
(when Yes-Text (#/addButtonWithTitle: Alert (native-string Yes-Text)))
(when No-Text (#/addButtonWithTitle: Alert (native-string No-Text)))
(when Cancel-Text (#/addButtonWithTitle: Alert (native-string Cancel-Text)))
(when Explanation-Text (#/setInformativeText: Alert (native-string Explanation-Text)))
(#/setAlertStyle: Alert (if Is-Critical #$NSCriticalAlertStyle #$NSWarningAlertStyle))
(case (#/runModal Alert)
(#.#$NSAlertThirdButtonReturn (throw :cancel nil)))))
(defvar *Evidence-of-Login-Execution* nil)
(defun LOGIN ()
(setq *Evidence-of-Login-Execution* t)
(standard-alert-dialog "Too good to be true?"))
(pushnew 'login ccl::*restore-lisp-functions*)
(ccl::build-application :name "Crasher")
Prof. Alexander Repenning
University of Colorado
Computer Science Department
Boulder, CO 80309-430
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Openmcl-devel