Thanks Wayne, that makes sense. It's still frustrating that I can't send actions to the originating control, but I can see why what you're suggesting is more like the "right" way of doing this! Cheers Jonny
On 2 Mar 2011, at 10:32, Wayne Packard wrote: > Hi Jonathan, > > I think the more common way of doing this would be to have a controller class > that has outlets for the text fields and an action for the button. Wire them > up in IB. In the action handler for the button press, get and set the values > in the text fields. > > If you have multiple buttons tied to multiple fields, you can either assign a > different handler to each button or, as is more common, examine the sender > that is passed to the button action handler to figure out which button was > pressed and act accordingly. > > If you have lots of fields, you could avoid creating outlets for all of them > by using distinct tags to find and operate on them. > > You won't need a custom button to accomplish this behavior (though you may > have another reason for subclassing it). > > wp > > Sent from my iPad > > On Mar 2, 2011, at 1:57 AM, Jonathan Taylor <j.m.tay...@durham.ac.uk> wrote: > >> It seems that InterfaceBuilder won't let me wire up my custom control to >> send an action to itself. This suggests to me that I am going the wrong way >> about what I am trying to do, or missing something really obvious. Can >> anybody advise? >> >> My window has a number of text fields. One represents the current position >> of an attached translation stage, and other represent limits on its motion. >> I have a "set" button next to the limit fields which cause them to set their >> value to the current position of the stage. I think the tidiest way of >> coding this is to have a custom button class with outlets connecting it to >> the source and destination text fields, which when clicked executes >> something like: >> [dest takeIntValueFrom:src]; >> >> I don't think I can do this purely within IB, without a custom class, since >> I want the target control to take its value from a third control, not from >> the sender [the button]. However, ridiculous as it seems, I can't actually >> work out the right way of executing an action defined in the button itself >> when it is clicked. IB won't let me wire up an action to itself(*). >> >> How can I go about executing an action defined in the button class itself? >> (Or why am I going about this the wrong way?). >> >> Thanks for any suggestions >> Jonny >> >> >> (*) actually, I swear I did manage to wire this up once, but I can't get it >> to happen again. Now when I try to do it, I can drag from Sent >> Actions/selector to any other object, but not to the sending button. >> >> _______________________________________________ >> >> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) >> >> Please do not post admin requests or moderator comments to the list. >> Contact the moderators at cocoa-dev-admins(at)lists.apple.com >> >> Help/Unsubscribe/Update your Subscription: >> http://lists.apple.com/mailman/options/cocoa-dev/wpackard%40mac.com >> >> This email sent to wpack...@mac.com _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com