Re: Changing order of views dynamically
Re: Changing order of views dynamically
- Subject: Re: Changing order of views dynamically
- From: Sergey Shapovalov <email@hidden>
- Date: Mon, 19 Mar 2007 17:40:03 +0300
Patrick, thank you for your answer.
On Mar 19, 2007, at 5:15 PM, PGM wrote:
If you need to swap views dynamically, you can put them in a
borderless NSTabView and then change the tab programmatically. This
also makes your nib easier to maintain than having a nib with
overlapping views (which is, as stated anyway not supported).
However, it looks like you didn't get my point. Let me try to explain
it again.
1. The overlapped controls don't come from a NIB. I create them
dynamically at run time.
2. I don't need to swap the views. I need to swap the *order* of the
views.
Well, what I'm implementing is pretty much like a time-line control
many video editors have. I have a custom control for every frame (for
simplicity, let's consider it just a button). These "frames" are
grouped inside a scroll view. At run time, I can insert more "frames"
into the scroll view (add them to the end). New "frames" are located
above the previous ones (because I call [NSView
addSubview:positioned:relativeTo:] with NSWindowAbove flag).
When I start dragging the "frames" and change their left-to-right
order, I want them to change their back-to-front position as well. I
want right controls be always positioned above left controls (if they
overlap).
One solution I already know is to call removeFromSuperview and then
addSubview:positioned:relativeTo: to remove a "frame" from the
superview and then insert it in the proper back-to-front position.
But this looks like a dirty hack, and besides, if I do so, this stops
the dragging procedure.
My original question was: is their a "fair" API to do this trick? And
if there is no, what is the best workaround for my purpose?
Concerning the phrase that views overlapping is not well supported...
What exactly is meant by this? Cocoa does provide API like [NSView
addSubview:positioned:relativeTo:]. Interface Builder has commands
Layout > Bring To Front / Send To Back, and both seem to work all
right... What exactly is not supported?
Best regards,
Sergey.
_______________________________________________
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