Re: How to join two controls together?
Re: How to join two controls together?
- Subject: Re: How to join two controls together?
- From: Erik Thorteran <email@hidden>
- Date: Sun, 4 Nov 2001 08:35:39 -0800
Howdy, the way I would do it is (as you said) make them outlets of
each other and takeFloatValue from one-another. However, i would
make your eventual target the /delegate/ of the NSTextField, and
wait for controlTextIsChanging, and then you get what you are
expecting. However, you would have a bunch of things to take into
account. Alternatively, group the two as a custom view, and make
the custom view a TLRStepperTextField and have the NSTextField's
delegate be the TLRStepperTextField, and then have the
TLRStepperTextField pass on the info to it's target. Two
alternative solutions, both with advantages and disadvantages. Try
one and report back!
Erik
On Saturday, November 3, 2001, at 03:18 AM, email@hidden wrote:
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.
_______________________________________________
MacOSX-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/macosx-dev