How to join two controls together?
How to join two controls together?
- Subject: How to join two controls together?
- From: email@hidden
- Date: Sat, 3 Nov 2001 12:18:31 +0100
Hi Cocoa gurus,
This is more a question about OO style in Cocoa+IB+PB but I can't find a
satifactory solution.
I would like to have two controls "joined together" (don't know if this
sounds correct in english, sorry). Namely I have a NSTextField (containing
a number) and a NSStepper (allowing to change this number easily). It is
rather easy (but cumbersome) to have them working correctly: both should
have the same action, target the controller, and the controller would
ensure that they keep the same value internally.
But this doesn't look like the "right" way. I would like to have them
behave as a unique control (which they rreally are). This is rather
important for me, because I have a lot of such pairs in my app. For each
pair I need two outlets in the controller, and the action is more
complicated.
Here are the difficult things (for me). I just don't know how to do that.
Sure I can subclass NSControl, or NSTextField (though this one it's
difficult), but how to have the stepper drawn and working as expected? And
would it be possible to have IB handle the connections for this object?
Note: I already tried the following: each control is the target of the
other, with action "takeFloatValueFrom:"; and the controller listen the
notification "controlTextDidChange". But this doesn't work as expected,
since the changes in NSStepper are not continuously taken into account
(the notification is not sent: you have to hit enter in the text field).
Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.