• 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: Andrei Tchijov <email@hidden>
  • Date: Mon, 13 Mar 2006 23:02:17 -0500

Very true.

Thanks.

On Mar 13, 2006, at 10:56 PM, Greg Herlihy wrote:

I would think that this code would work for your purposes:

    id superview = startView;

    while (superview)
    {
        if ([superview isKindOfClass:[NSTabView class]])
            return [superview selectedTabViewItem];

        superview = [superview superview];
   }
   return nil;

Presumably whichever NSTabViewItem the pane belongs to, is the currently
selected one in its NSTabView - otherwise how could the action be generated
from a non-visible view?


Greg

On 3/13/06 12:36 PM, "Andrei Tchijov" <email@hidden> 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: 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: 
 >Re: How to find the name of the tab view item if you have one of its sub-views(sub-sub-views)? (From: Greg Herlihy <email@hidden>)

  • Prev by Date: Re: How to find the name of the tab view item if you have one of its sub-views(sub-sub-views)?
  • Next by Date: Releasing Object belonging to Core Data transient attribute
  • 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: Xcode won't compile a Universal Binary
  • Index(es):
    • Date
    • Thread