Re: NSTabView; How to get the current / active tab ..?
Re: NSTabView; How to get the current / active tab ..?
- Subject: Re: NSTabView; How to get the current / active tab ..?
- From: Scott Andrew <email@hidden>
- Date: Sun, 7 Jun 2009 19:25:42 -0700
Duh.. So a bit of correction to my code.
#define GENERAL_TAB 100
#define FONT_TAB 101
NSTabViewItem* item = [tabView selectedTabViewItem];
switch ([[item identifier] intValue])
{
case GENERAL_TAB:
NSLog(@"Tab 1");
break;
case FONT_TAB:
NSLog(@"Tab 2");
break;
}
}
On Jun 7, 2009, at 6:54 PM, Andy Lee wrote:
Well, [tabViewItem identifier] returns an id, not an int, but the
general idea is probably a good one -- decide your action based on
the identifier rather than the position of the tab, in case you
decide to rearrange the tabs later.
--Andy
On Jun 7, 2009, at 9:36 PM, Scott Andrew wrote:
Why not use unique identifiers for each tab item? Each
NSTabViewItem has an identifier value. Using that and some defines
you can use do the following:
#define GENERAL_TAB 1
#define FONT_TAB 2
NSTabViewItem* tabViewItem = [tabView selectedTabViewItem];
switch([tabViewItem identifier])
{
case GENERAL_TAB:
NSLog(@"1");
break;
case FONT_TAB
NSLog(@"2");
break;
}
Scott
On Jun 7, 2009, at 11:14 AM, Martin Batholdy wrote:
hi,
I have an IBOutlet defined in my header;
IBOutlet NSTabView *tabView;
This Outlet is connected with a TabView generated with Interface
Builder.
The TabView has two tabs,
and in my implementation file I want to do something when tab1 is
active and something else when tab2 is active.
I tried the following;
NSTabViewItem *tabViewItemX;
tabViewItemX = [tabView selectedTabViewItem];
if([tabViewItemX isEqualTo:[tabView tabViewItemAtIndex:0]]){
NSLog(@"1");
} else{
NSLog(@"2");
}
But it doesn't work properly. It is just always "2".
What do I wrong?
thanks!
_______________________________________________
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
_______________________________________________
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