Re: Hiding tab view items
Re: Hiding tab view items
- Subject: Re: Hiding tab view items
- From: BareFeet <email@hidden>
- Date: Fri, 29 Jan 2010 13:54:32 +1100
Hi all,
I am just following up on my previous queries about how to show a hierarchy of Nodes in the left pane (like iTunes or Disk Utility) and have the available tab view items on the right change according to the type of node that the user selects.
Thanks to Volker, Kyle, Nathan and "Idiot Savant" for earlier replies. I think I understand now how to retain tab view items so they can be removed and reinserted.
I managed to set up my tab view to remove and reinsert particular tab views according to what Node is selected, by using the NSOutlineView delegate method. I first retain all the tab view items in the awakeFromNib handler. The example below checks whether the selected nodeType is "table". It then removes or inserts the tab view item with the identifier "Table" in the tab view.
This seems to work OK so far. If I've goofed anywhere, please let me know, via the mail list.
@interface MyController : NSObject
{
IBOutlet NSTabView* tabView;
IBOutlet NSTreeController* nodeTreeController;
NSArray* retainedTabViewItems;
}
@end
@implementation MyController
- (void) awakeFromNib
{
retainedTabViewItems = [tabView tabViewItems];
[retainedTabViewItems retain];
}
- (void) dealloc
{
[retainedTabViewItems release];
[super dealloc];
}
- (void) outlineViewSelectionDidChange:(NSNotification*)notification
{
NSString* nodeType = [nodeTreeController valueForKeyPath:@"selection.type"];
NSInteger visibleTabViewItemIndex = [tabView indexOfTabViewItemWithIdentifier:@"Table"];
NSTabViewItem* retainedTabViewItem = nil;
for (int tabViewItemIndex = 0; tabViewItemIndex < [retainedTabViewItems count]; tabViewItemIndex++)
{
retainedTabViewItem = [retainedTabViewItems objectAtIndex:tabViewItemIndex];
NSString* retainedTabViewItemIdentifier = [retainedTabViewItem identifier];
if ([retainedTabViewItemIdentifier isEqualToString:@"Table"]) break;
}
BOOL tabViewItemShouldShow = [nodeType isEqualToString:@"table"];
BOOL tabViewItemDoesShow = visibleTabViewItemIndex != NSNotFound;
if (tabViewItemShouldShow && !tabViewItemDoesShow)
{
[tabView insertTabViewItem:retainedTabViewItem atIndex:3];
}
else if (!tabViewItemShouldShow && tabViewItemDoesShow)
{
[tabView removeTabViewItem:retainedTabViewItem];
}
}
// other code omitted
@end
----
From: BareFeet <email@hidden>
Date: 21 October 2009 6:02:21 PM AEDT
To: Cocoa Dev <email@hidden>
Subject: Re: Hiding tab view items
This seems like a common requirement, so I keep thinking I must be missing something simple.
For an example of similar functionality, look at Disk Utility. The user can navigate through a tree of nested disks and partition nodes in the left view. The right view shows a tab view that changes its tab items depending on what tree node is selected on the left. For instance, if you select a disk, you see the tab view items: First Aid, Erase, Partition, RAID and Restore. But if you select a partition, the "Partition" tab view item disappears.
Since there is no hidden/visible property for tab view items, it seems that I have to dynamically delete and create tab view items
<snip>
----
From: BareFeet <email@hidden>
Date: 13 October 2009 1:53:03 AM AEDT
To: Cocoa Dev <email@hidden>
Subject: Hiding tab view items
Hi all,
I have a hierarchical list of objects, like the typical iTunes or XCode left pane. When the user selects a node in this hierarchy, I display detail of that node in the pane on the right. This right pane is divided into tab view items. Only some of the tab view items are relevant to each type of node, so I'd like to hide the tab view items that are not relevant. How can I do this?
In Interface Builder, I can't see any "hidden" property of tab view item. There is a "hidden" property for the sub-view of a tab view item, but this doesn't hide the tab view item itself, so is misleading to the user (ie they can click on it, only to see a blank view).
<snip>
_______________________________________________
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