Re: passing messages to parent controls?
Re: passing messages to parent controls?
- Subject: Re: passing messages to parent controls?
- From: Ricky Sharp <email@hidden>
- Date: Thu, 27 Jan 2005 10:05:30 -0600
On Thursday, January 27, 2005, at 09:39AM, Matt Neuburg <email@hidden> wrote:
>On Thu, 27 Jan 2005 19:35:01 +1100, Duncan Campbell
><email@hidden> said:
>>Hi folks,
>>
>>I'm building my own tabs to mimic the way that safari tabs work (with
>>the nice mouse-over effects etc).
>>
>>Each tab is an NSView subclass with an image on it for the "close"
>>button. I then have a wrapper class that creates the tab-bar that each
>>tab sits on (basically an array of tab items). Each tab item has 2
>>events - 1 for the tab select click, and 1 for the close-button click.
>>
>>My question is: Since these events take place in the tab item class
>>itself, how do i send them back to the tab-bar class so that it can be
>>notified that a tab has been clicked (or closed) and take the
>>appropriate action (select the tab, or close the tab/remove from
>>array).
>
>They are your classes, so it is your job to provide each tab item with a
>pointer to the tab-bar at the time that the tab item is created as a
>"member" of that tab-bar. m.
You can definitely do this. But, you may also want to explore having your tab be a subclass of NSCell. Then, have your tab bar be a subclass of NSControl (perhaps even NSMatrix) to provide you with control over multiple cells (tabs).
In such a combo, you then provide an implementation of controlView in your NSCell subclass. It will simply return the NSView instance that the view belongs to. You typically add an NSView* attribute to the NSCell subclass and set it to the value provided to you in methods such as drawInteriorWithFrame:inView:. Something like this...
@interface MyCell : NSCell
{
MyControl* controlView;
}
...
@implementation MyCell
- (NSView*)controlView
{
return controlView;
}
- (void)drawInteriorWithFrame:(NSRect)aFrame inView:(NSView*)aView
{
controlView = aView;
...
}
...
And, when you need to communicate to the control, just do stuff like [[self controlView] someMessage];
--
Rick Sharp
Instant Interactive(tm)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden