[Openmcl-devel] NSSlider not responsive

Osei Poku osei.poku at gmail.com
Sat Feb 2 08:06:17 UTC 2008


On Feb 2, 2008, at 2:53 AM, Gary Byers wrote:

>>
>>
>> (defclass window-controller (ns:ns-object)
>> ((model :foreign-type :id :accessor model)
>>  (slider :foreign-type :id :accessor slider))
>> (:metaclass ns:+ns-object))
>
> There is a class - NSWindowController - that might be useful
> to subclass here.
>
>>
>> (objc:defmethod #/slide: ((self window-controller) sender)
>> (let ((val (#/floatValue sender)))
>>   (setf (model-value (model self)) val)
>>   (#/setNeedsDisplay: (model self) t)))
>
> I don't think that #/slide is sent by anything in Cocoa; sorry if  
> there's
> some missing IB stuff that arranges for that to happen.
>
> If not: NSSlider is a subclass of NSControl, and an NSControl can have
> an "action" method that's sent to some "target" object whenever it's
> changed; there are #/setAction: and #/setTarget: methods that can set
> these things up procedurally, and you can also set these things up in
> IB.
>
> If you intend for your window-controller class to be a subclass of
> NSWindowController, you can arrange (in IB) that an instance of that
> class will control the window and also arrange that it be the target
> of the slider and receive #/slide from the slider (as the slider's
> action message.)  It seems that this is likely to be what you want,
> but I'm not really sure how that would happen if WINDOW-CONTROLLER
> is just a sunclass of NS:NS-OBJECT (rather than being a subclass
> of NS:NS-WINDOW-CONTROLLER).
>

Yes. The IB aspect is hidden here and I do confirm that the slider  
activates the #/slide method.  The rectangle does indeed change  
shape.  I will look into the NSWindowController class, but what I do  
now works to connect the right targets with the right actions.

Osei




More information about the Openmcl-devel mailing list