[Openmcl-devel] Uncle!

R. Matthew Emerson rme at clozure.com
Sat Nov 3 18:49:37 PDT 2007

On Nov 3, 2007, at 8:42 PM, Ron Garret wrote:

>> The idiomatic way of setting up a window's view hierarchy is by
>> obtaining the window's content view (#/contentView window) and
>> then adding subviews to that.  A simple example of this is available
>> at:
>> <http://trac.clozure.com/openmcl/wiki/CocoaBridge>
> That doesn't really show how to add subviews, just how to set up the
> original contentView.  But I'm making good progress and I'm sure I'll
> figure it out sooner or later.

Something like:

(setf *v* (show-red-window))
(let* ((b (make-instance 'ns:ns-button :with-frame (ns:make-ns-rect 0  
0 0 0))))
   (#/setTitle: b #@"this does nothing")
   (#/setBezelStyle: b #$NSRoundedBezelStyle)
   (#/sizeToFit b)
   (#/addSubview: *v* b)
   (#/setFrameOrigin: b (ns:make-ns-point 30 30))
   (#/release b))

To position a subview, update the subview's frame (with #/setFrame:, #/ 
setFrameOrigin: or whatever.)

Apple's View Programming Guide is worth a look, if only just to get  
acquainted with the frame/bounds distinction, and a few other bits of  
terminology and background.


More information about the Openmcl-devel mailing list