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 12:31:36 +0300
Michael, thank you for your answer!
Let me explain what I'm going to achieve in the result (I think I had
to start with this in my original post). In my application, I have a
horizontal scroll view. I can add controls to the scroll view
dynamically at run time. Consider these controls as buttons, though
actually these are some custom controls. I can also drag these
controls to the left and to the right inside this scroll view.
Now why I need changing order of views (controls actually) on the
fly. Originally I have controls (left to right) C1, C2, C3 in the
scroll view. They are ordered C1 below C2 below C3 in case they
overlap. Then I begin dragging, and C3 appears between C1 and C2. At
this moment, I want the order to change and become C1 below C3 below
C2 (I want left controls always be below right controls).
Is there a way to implement this functionality?
And what about nesting controls - what is this and can it work in my
case? Sorry if this is a naive question, but I'm relatively new with
Cocoa... Is nesting a kind of grouping? Where can I read about it?
Best regards,
Sergey.
On Mar 19, 2007, at 12:15 PM, Michael Watson wrote:
Views aren't like windows in Cocoa. That's the short answer.
The long answer is that windows can be overlapped, but views cannot
be overlapped reliably; views are /nested/ instead. Whatever it is
that you're doing, don't rely on the order in which your views are
added to a hierarchy, and don't overlap views. Nest them instead.
--
m-s
On 19 Mar, 2007, at 04:23, Sergey Shapovalov wrote:
Hello all!
I'm trying to figure out if there's a way to change the order of
views in a window dynamically.
When I create a window, I can set its order relatively to another
window by calling [NSWindow addChildWindow:ordered:]. At run-time,
I can change the windows z-order by calling [NSWindow orderBack:],
[NSWindow orderFront:], or [NSWindow orderWindow:relativeTo:].
With views, I can set their order at the moment of creation by
calling [NSView addSubview:positioned:relativeTo:]. But I can't
find a function to change the order of views at run-time. Am I
just blind for not seeing the proper method, :) or is this task
more complicated and it doesn't imply just one line of the code?
If so, can anybody drop me a hint concerning how this can be done?
Best regards,
Sergey Shapovalov.
_______________________________________________
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:
40bungie.org
This email sent to 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