Re: Hiding tab view items
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 list.develo...@tandb.com.au Date: 21 October 2009 6:02:21 PM AEDT To: Cocoa Dev Cocoa-dev@lists.apple.com 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 list.develo...@tandb.com.au Date: 13 October 2009 1:53:03 AM AEDT To: Cocoa Dev Cocoa-dev@lists.apple.com 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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
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, which is prohibitively complicated since those tab view items also contain other objects which must therefore also be dynamically created and deleted. At the moment, I've set up my tab view as tabless (ie the actual tabs don't show). Instead of tabs, I've created several segmented controls, one showing each desired set of segments. I've created a small second tabless tab view where each tab just contains one of the segmented controls. When the user selects a tree node (in the left pane), bindings switches to the tab containing the desired segmented control. When the user clicks on a segment, bindings then switches to the tab view corresponding to that segment. user selects tree node - bindings selects small tab view item which contains just the desired segmented control user selects segment in segmented control - bindings selects large tab view item which contains all the necessary objects This works and requires almost no code (just bindings), so it's relatively neat. But it seems silly to have to create a second tab view just to switch between different segment controls. Any other insights? Thanks, Tom BareFeet ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Hiding tab view items
On Wed, Oct 21, 2009 at 12:02 AM, BareFeet list.develo...@tandb.com.au wrote: This seems like a common requirement, so I keep thinking I must be missing something simple. Nope. You're going to need to write code. The hardest part is replacing the tab view items; this really isn't that difficult: // Typed in Mail - (void)updateTabView:(NSTabView *)tabView withItems:(NSArray *)newItems; { NSArray *oldItems = [tabView tabViewItems]; NSInteger newLocation = 0; for (NSTabViewItem *newItem in newItems) { NSInteger existingLocation = [tabView indexOfTabViewItem:newItem]; if (existingLocation != NSNotFound) [tabView removeTabItem:newItem]; [tabView insertTabViewItem:newItem atIndex:newLocation++]; } for (NSTabViewItem *oldItem in oldItems) if (![newItems containsObject:oldItem]) [tabView removeTabViewItem:oldItem] } --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Hiding tab view items
In general hiding bit of you interface depending on the state/ selection of you app is considered bad because it can confuse the user, if you disable elements then you are tell the user that the element is not available for the current state/selection etc., if you you hide elements then the user may think they have forgotten how to get to a particular feature and become frustrated as they try to find it. Also hiding elements can in some cases cause the remaining elements to move around which can allow confuse users (menu items for example), I am not saying you are wrong to do this in your case, only you can decided that. On 13/10/2009, at 1:53 AM, BareFeet wrote: 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? Nathan Day http://homepage.mac.com/nathan_day/ ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Hiding tab view items
Thanks for the reply, Kyle. [tabView removeTabViewItem:oldItem] But isn't that going to destroy the tab item, the view it contains, and everything in that view? Can I get it back when that tab view item is valid again, or do I have to programmatically create all the objects? Thanks, Tom BareFeet ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Hiding tab view items
On Oct 21, 2009, at 9:03 AM, BareFeet wrote: [tabView removeTabViewItem:oldItem] But isn't that going to destroy the tab item, the view it contains, and everything in that view? Can I get it back when that tab view item is valid again, or do I have to programmatically create all the objects? Not if you retain it and assign it to an ivar to keep it around. -- I.S. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Hiding tab view items
there a different roots to success Thanks for the input. a) roll your own Tabs instead of Segmented cell in combination with a tabless NSTabView Do you mean use a segmented control with a tabless NSTabView, where each segmented cell is linked to a tab view? I have set that up, but can't see a way to hide a segmented cell. I can turn off the enabled flag (in Interface Builder of via the accessor method), but there doesn't appear to be a hidden flag. I thought I might be able to set the width to zero, but the documentation says: setWidth:forSegment: The width of the segment, measured in points. Specify the value 0 if you want the segment to be sized to fit the available space automatically. So I guess I'll have to build the segmented control dynamically from scratch each time I want to hide a segmented cell, just leaving out that cell in the rebuild. b) Add/remove tab items on demand That sounds similar to above. However, I feel more comfortable rebuilding just a segmented cell than trying to delete and rebuild a whole view. Seems messy either way though. Thanks, Tom BareFeet ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
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). I tried using a segmented control, instead, using bindings to link it to the tab view (now tabless). But segmented control cells also seem to lack a hidden property. Any ideas? Thanks, Tom BareFeet ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Hiding tab view items
Hi, there a different roots to success a) roll your own Tabs instead of Segmented cell in combination with a tabless NSTabView b) Add/remove tab items on demand Both are fairly easy to achieve with some pitfalls like view retains and such. I am using the b) route for something similar and am swapping in and out views in a splitview pane on account of user choices. I also used route a) for an intelligent inspector without problems. Cheers, Volker Am 12.10.2009 um 16:53 schrieb BareFeet: 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). I tried using a segmented control, instead, using bindings to link it to the tab view (now tabless). But segmented control cells also seem to lack a hidden property. Any ideas? Thanks, Tom BareFeet ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/volker_lists%40ecoobs.de This email sent to volker_li...@ecoobs.de ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com