Moving subviews to other window
Moving subviews to other window
- Subject: Moving subviews to other window
- From: Lorenzo <email@hidden>
- Date: Thu, 14 Dec 2006 11:29:12 +0100
Hi,
I have to move all the 4 views from a window to another window.
I use subviews: and addSubview: and it works pretty well.
The subviews array is sorted from the back to the front object, so
since I have to add the subviews in the same order, and cannot remove the
first subview from the subviews array without causing troubles, I use a
reverse array. Well, now the 4 views are in the new window, with the proper
sort order, but one of the 4 views, containing other subviews, shows its
subviews with a different sort order. Bad.
I supposed that adding a subview should not affect the sort order of its
subviews but it seems that I was wrong. Did I miss something? Any idea?
NSView *oldContentView = [oldWindow contentView];
NSArray *sub = [oldContentView subviews];
int totObj = [sub count];
NSMutableArray *inverseObjs = [NSMutableArray array];
for(i = totObj - 1; i >= 0 ; i--){
[inverseObjs addObject:[sub objectAtIndex:i]];
}
for(i = totObj - 1; i >= 0 ; i--){
id obj = [inverseObjs objectAtIndex:i];
[obj removeFromSuperview];
[newContentView addSubview:obj];
}
I even tried to do, in one line only:
[newWindow setContentView:[oldWindow contentView]];
but it creates problem. It seems that the old window still responds to the
subviews.
Best Regards
--
Lorenzo
email: email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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