I'm trying to run the "hello world" script provided by Clozure for the CCL-Cocoa bridge:
https://trac.clozure.com/ccl/wiki/CocoaBridge
Load the file containing these forms, evaluate (show-red-window), and you'll see a red window.
red-window.ccl
(in-package "CL-USER")
(require "COCOA")
(defclass red-view (ns:ns-view)
()
(:metaclass ns:+ns-object))
(objc:defmethod (#/drawRect: :void) ((self red-view) (rect :<NSR>ect))
(#/set (#/redColor ns:ns-color))
(#_NSRectFill (#/bounds self)))
(defun show-red-window ()
(ccl::with-autorelease-pool
(let* ((rect (ns:make-ns-rect 0 0 300 300))
(w (make-instance 'ns:ns-window
:with-content-rect rect
:style-mask (logior #$NSTitledWindowMask
#$NSClosableWindowMask
#$NSMiniaturizableWindowMask)
:backing #$NSBackingStoreBuffered
:defer t)))
(#/setTitle: w #@"Red")
(#/setContentView: w (#/autorelease (make-instance 'red-view)))
(#/center w)
(#/orderFront: w nil)
(#/contentView w))))
But when I run ccl64
and type
(load "red-window.ccl")
(show-red-window)
I just get this output on the terminal:
#<RED-VIEW <RedView: 0x4cd530> (#x4CD530)>
and nothing else appears to happen.
Am I missing something? I'm new to both CL and Cocoa.
Try
(gui:execute-in-gui #'(lambda () (show-red-window)))
The page with the red window example was last updated 10 years ago. One of the other examples from was last modified 13 days ago to include gui:execute-in-gui
.