• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to find the name of the tab view item if you have one of its sub-views(sub-sub-views)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to find the name of the tab view item if you have one of its sub-views(sub-sub-views)?


  • Subject: Re: How to find the name of the tab view item if you have one of its sub-views(sub-sub-views)?
  • From: Mike Abdullah <email@hidden>
  • Date: Mon, 13 Mar 2006 23:29:02 +0000

Um, sorry Keith, but you seem to have got the wrong end of the stick!

I was answering someone else's question on how to find out which tab view item a particular view is in. I.e. say you are given a text field, you want to find out which section of your tabview it's in.

At least, I think that's what he was after!

Mike.

On 13 Mar 2006, at 23:17, Keith Wilson wrote:

Hi Mike,

The Tabview identifier can be set in IB as a string but later be reassigned to any Object.

Let's assume that each tab contains an NSTtableView called pTable1, pTable2, pTable2 and these have IBOutlets in the controller for your tabview,

In Interface Builder give each tab in the tabview an Identifier - a NSString - that is called table1, table2, table3, etc

In awakeFromNib change each tab identifier to be the NSTableView object table1, table2, table3, etc using

	if(tvi identifier] isEqualToString:@"table1"]
		[tvi setIdentifier:pTable1];
	if(tvi identifier] isEqualToString:@"table2"]
		[tvi setIdentifier:pTable2];
	etc ....

Now each tab knows the object that it is associated with without worrying about traversing the view hierarchy and you can do things like

	NSTabViewItem *tvi = [pTabView selectedTabViewItem];
	if([[tvi identifier] respondsToSelector:@selector(doSomething:)])
		[[tvi identifier] doSomething:xxxxt];

Keith from DownUnder



On 14/03/2006, at 9:40 AM, Mike Abdullah wrote:

To clarify, are you saying that your app knows of a particular view, and you would to find out which tab of your tab view it is in?

Mike.

On 13 Mar 2006, at 20:36, Andrei Tchijov wrote:

In my application I need to get reference to NSTabViewItem object starting with its sub-sub-view. Firstly, I tried to traverse views hierarchy via "[ view superview ]", but soon discovered that NSTavViewItem object could not be found this way. After some tinkering I come up with this :

			...
			id superview = [ startView superview ];
			id subview = startView;

while (( superview != nil ) && ( ! [ superview isKindOfClass: [ NSTabView class ]] )) {
subview = superview;
superview = [ superview superview ];
}
NSArray* tabViewItems = [ superview tabViewItems ];
for( int i = 0; i < [ tabViewItems count ]; i++ ) {
if( [[ tabViewItems objectAtIndex: i ] view ] == subview ) {
subview = [ tabViewItems objectAtIndex: i ];
break;
}
}
...


It works, but does not look right. I can not believe that there is no better(simplier) way of doing it.

Any comments, suggestions will be highly appreciated	

Andrei Tchijov


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40bigpond.net.au


This email sent to email@hidden


_______________________________________________ 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
References: 
 >How to find the name of the tab view item if you have one of its sub-views(sub-sub-views)? (From: Andrei Tchijov <email@hidden>)
 >Re: How to find the name of the tab view item if you have one of its sub-views(sub-sub-views)? (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: Getting local timezone as integer
  • Next by Date: Re: DragItemAround sample code
  • Previous by thread: Re: How to find the name of the tab view item if you have one of its sub-views(sub-sub-views)?
  • Next by thread: Re: How to find the name of the tab view item if you have one of its sub-views(sub-sub-views)?
  • Index(es):
    • Date
    • Thread