Re: InterfaceBuilder - send action to self?
Re: InterfaceBuilder - send action to self?
- Subject: Re: InterfaceBuilder - send action to self?
- From: Wayne Packard <email@hidden>
- Date: Wed, 02 Mar 2011 02:32:29 -0800
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 <email@hidden> 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 (email@hidden)
>
> 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:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden