Re: Oddity with Windows
Re: Oddity with Windows
- Subject: Re: Oddity with Windows
- From: Matt Neuburg <email@hidden>
- Date: Tue, 27 Aug 2002 08:04:55 -0700
On Mon, 26 Aug 2002 22:37:50 -0700, Adam Thayer <email@hidden> said:
>
I am trying to setup a sheet before opening it, without actually forcing
>
myself to link the sheet's items to a class using IB first (for the sake
>
of possible future functionality).
I'm in complete sympathy with your aims.
>
The method works this way so far: grab
>
the view for the sheet, and then start grabbing subviews via tags I place
>
on the items... This works okay except for some small glitches. The main
>
one is that I cannot find subviews if the tabgroup I use is not set to the
>
particular tab
Certainly you can find them. You just can't find them using NSView's
viewWithTag, which is decidedly weenie (a technical programming term). My
solution is the following, which I add to NSView in a category. It knows
how to drill down into tabviewitems and matrices in the hunt for a tag
value.
- (id) myViewWithTag: (int) i {
id obj = [self viewWithTag: i];
if (obj) return obj;
// didn't find it, look in other ways
if ([self isKindOfClass: [NSTabView class]]) {
// look thru all tabs
NSEnumerator* ee;
NSTabViewItem* tvi;
ee = [[(NSTabView*) self tabViewItems] objectEnumerator];
while ((tvi = [ee nextObject])) {
id obj = [[tvi view] myViewWithTag: i];
if (obj) return obj;
}
} else if ([self isKindOfClass: [NSMatrix class]]) {
NSEnumerator* ee;
id c;
ee = [[(NSMatrix*) self cells] objectEnumerator];
while ((c = [ee nextObject])) {
if ([c tag] == i) return c;
}
} else {
NSEnumerator* ee;
NSView* aView;
ee = [[self subviews] objectEnumerator];
while ((aView = [ee nextObject])) {
id obj;
obj = [aView myViewWithTag: i];
if (obj) return obj;
}
}
return nil;
}
m.
--
matt neuburg, phd = email@hidden,
http://www.tidbits.com/matt
pantes anthropoi tou eidenai oregontai phusei
Subscribe to TidBITS! It's free and smart.
http://www.tidbits.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.