Re: IB3 and custom controls: problem with actions
Re: IB3 and custom controls: problem with actions
- Subject: Re: IB3 and custom controls: problem with actions
- From: "Vitaly Ovchinnikov" <email@hidden>
- Date: Sun, 6 Jul 2008 02:25:04 +0400
Chris, I have complex controls, so I don't think it's a good idea to
post all the code here. Let's imagine, that I need a control that
sends an action when I click it. So, the declaration will look like
this:
@interface MySuperControl : NSControl
{
// no data
}
// no methods
@end
implementation will look like this:
@implementation MySuperControl
- (void) mouseDown: (NSEvent *) evt
{
[self sendAction:[self action] to:[self target]];
}
- (void) drawRect: (NSRect) rc
{
// fill the control with some color...
}
@end
pretty simple piece of code, just to show the idea. I created several
controls in XCode 2.5, connected them all without a problem, but in
3.0 I can't do the same...
Actually, I never heard that I need to declare "sent" actions. I read
about IBAction and IBOutlet and it seems that they're all that IB
needs to know. Am I wrong?
On Sun, Jul 6, 2008 at 12:47 AM, Chris Hanson <email@hidden> wrote:
> On Jul 3, 2008, at 11:19 PM, Vitaly Ovchinnikov wrote:
>
>> After upgrade to XCode 3.0 I found out that now it is impossible. Old
>> links are still alive (marked with yellow triangles), but I can't
>> create a new one. I don't see "Sent action" group by right-clicking my
>> controls. If I perform Ctrl+Drag from my control to the controller -
>> it doesn't highlited. But if I do the same for NSButton - all works
>> fine.
>
> That means Interface Builder doesn't know your controller implements those
> actions.
>
> The actions a control can send are not part of the control, but are part of
> whatever you are sending an action to. Thus your controller needs to have
> those actions declared in a header file in your project (or in a framework
> referenced by your project) in order for Interface Builder to recognize
> them.
>
> What does the declaration of your controller look like?
>
> -- Chris
>
>
>
_______________________________________________
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