[Openmcl-devel] NSApplication run method does not seem to work quite right

Willem Rein Oudshoorn woudshoo at xs4all.nl
Sat Mar 8 11:59:25 PST 2014


I am trying to use the objc bridge to create a GUI using the cocoa
framework.  However the way I try it does not seem to work quite right.

In Objective C I can do the following:


#import <Cocoa/Cocoa.h>

int 
main (int argn, char *argv[])
{
  NSApplication* app = [NSApplication sharedApplication];
  NSWindow* window = [[NSWindow alloc] initWithContentRect: NSMakeRect (100, 100, 300, 300)
						 styleMask: NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask
						   backing: NSBackingStoreBuffered
						     defer: YES];
  [window makeKeyAndOrderFront:nil];
  [app run];
  return 1;
}


When running this I get a resiable window which does work, I can resize
it etc.


If I do the equivalent in CCL with the objc bridge:

(require :objc-support)

(defparameter *app* nil)
(defun make-app ()
  (setf *app*
	(#/sharedApplication ns:ns-application)))

(defparameter *window* nil)
(defun make-window ()
  (setf *window*
	(ns:with-ns-rect (frame 0 600 300 300)
	  (make-instance 'ns:ns-window
			 :with-content-rect frame
			 :style-mask  (logior #$NSTitledWindowMask
					      #$NSClosableWindowMask
					      #$NSMiniaturizableWindowMask
					      #$NSResizableWindowMask)
			 :backing #$NSBackingStoreBuffered
			 :defer t))))


(defun start-run-loop ()
  (#/run *app*))


(defun test ()
  (make-app)
  (make-window)
  (#/makeKeyAndOrderFront: *window* nil)
  (process-interrupt ccl::*initial-process* #'start-run-loop))

(test)


It seems to work at first glance, however, I cannot resize the window
and I get the beach ball.  
So it seems that something goes wrong with handling events.   But I
cannot figure out what.

If someone has any hints where I can look, that is appreciated.

Note, I can get it to work by using (require :COCOA) and use the
infrastructure setup by the IDE.  (Not suprisingly :-)).

However I slightly prefer playing with cocoa without the CCL IDE.

Wim Oudshoorn.






More information about the Openmcl-devel mailing list