Re: How to anchor a child-window to its parent top-right (or other point) while parent resizes.

2012-07-29 Thread Motti Shneor

On 22 ביול 2012, at 19:52, Keary Suska wrote:

 On Jul 22, 2012, at 5:34 AM, Motti Shneor wrote:
 
 This seems a real newbie question, but the solutions I found seem too 
 complicated for my task.
 
 I have a non-NSPopover pop-over info window (can't use NSPopOver for many 
 reasons). 
 
 This popover like is just a window that draws itself  anchored to some 
 point in the parent window's coordinate system. Being a child-window of its 
 parent, it also moves with it, as expected. 
 
 When parent window is resized, the popover loses its anchor point, because 
 child-windows don't normally move when their parent resizes (no matter which 
 side of the parent window is changing). 
 
 That behavior is a bit weird, because when movement is synchronized, one may 
 guess that some point in the child window always moves with some other point 
 in the parent window, or at least with some origin point (top-left, 
 bottom-right, etc.) of the parent. None of this  happens.
 
 I could fix this by moving my child-window in the windowWillResize or 
 windowDidResize delegate of the parent, but it is not easy to know exactly 
 what happened (how did the anchor point on the parent, moved in 
 screen-coordinates) and so move the child-window. 
 
 I suspect the issue is that since the anchor is the origin point, which is 
 bottom-left, that resizing top/down is the issue since that would be the only 
 time that the window moves as a result.

Not so. You can drag-resize a window from all its edges these days, and NONE of 
the edges, when dragged, will cause the movement of the child-window. I admit I 
suspected the same as you --- that the child-window is anchored from its origin 
to the parent window's origin, but it turns to work differently. They only MOVE 
together, when the user MOVES the window, using movement APIs (or dragging). 
For that purpose, no resizing of the window, on any of its edges is considered 
movement.

 
 Depending on whether you want the child window to snap into place or to 
 live resize, OTOH, I would keep the *top*/right coordinate point of the child 
 window in the parent window's coordinate space, and then in -windowDidResize: 
 or windowWillResize:toSize: (for snap or live consecutively), or both, 
 perform a delta to see if that top/right point has changed, and then change 
 the relative position of the child window. Sounds pretty easy to me...

It is possible, of course, but somehow I was hoping to find a secret binding 
that could make this the child's window affair, without adding code on the 
parent window's controller. Maybe I can make the child-window's controller 
observe size-changes of the parent window, and realign itself. 

 
 HTH,
 
 Keary Suska
 Esoteritech, Inc.
 Demystifying technology for your home or business
 

Motti Shneor
e-mail: motti.shn...@gmail.com
phone: +972-8-9267730
mobile: +972-54-3136621

Ceterum censeo Microsoftinem delendam esse



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

How to anchor a child-window to its parent top-right (or other point) while parent resizes.

2012-07-22 Thread Motti Shneor
Hi.

This seems a real newbie question, but the solutions I found seem too 
complicated for my task.

I have a non-NSPopover pop-over info window (can't use NSPopOver for many 
reasons). 

This popover like is just a window that draws itself  anchored to some 
point in the parent window's coordinate system. Being a child-window of its 
parent, it also moves with it, as expected. 

When parent window is resized, the popover loses its anchor point, because 
child-windows don't normally move when their parent resizes (no matter which 
side of the parent window is changing). 

That behavior is a bit weird, because when movement is synchronized, one may 
guess that some point in the child window always moves with some other point in 
the parent window, or at least with some origin point (top-left, bottom-right, 
etc.) of the parent. None of this  happens.

I could fix this by moving my child-window in the windowWillResize or 
windowDidResize delegate of the parent, but it is not easy to know exactly 
what happened (how did the anchor point on the parent, moved in 
screen-coordinates) and so move the child-window. 

Any simpler ideas for such implementation?

Thanks.

Motti Shneor
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to anchor a child-window to its parent top-right (or other point) while parent resizes.

2012-07-22 Thread Keary Suska
On Jul 22, 2012, at 5:34 AM, Motti Shneor wrote:

 This seems a real newbie question, but the solutions I found seem too 
 complicated for my task.
 
 I have a non-NSPopover pop-over info window (can't use NSPopOver for many 
 reasons). 
 
 This popover like is just a window that draws itself  anchored to some 
 point in the parent window's coordinate system. Being a child-window of its 
 parent, it also moves with it, as expected. 
 
 When parent window is resized, the popover loses its anchor point, because 
 child-windows don't normally move when their parent resizes (no matter which 
 side of the parent window is changing). 
 
 That behavior is a bit weird, because when movement is synchronized, one may 
 guess that some point in the child window always moves with some other point 
 in the parent window, or at least with some origin point (top-left, 
 bottom-right, etc.) of the parent. None of this  happens.
 
 I could fix this by moving my child-window in the windowWillResize or 
 windowDidResize delegate of the parent, but it is not easy to know exactly 
 what happened (how did the anchor point on the parent, moved in 
 screen-coordinates) and so move the child-window. 

I suspect the issue is that since the anchor is the origin point, which is 
bottom-left, that resizing top/down is the issue since that would be the only 
time that the window moves as a result.

Depending on whether you want the child window to snap into place or to live 
resize, OTOH, I would keep the *top*/right coordinate point of the child window 
in the parent window's coordinate space, and then in -windowDidResize: or 
windowWillResize:toSize: (for snap or live consecutively), or both, perform a 
delta to see if that top/right point has changed, and then change the relative 
position of the child window. Sounds pretty easy to me...

HTH,

Keary Suska
Esoteritech, Inc.
Demystifying technology for your home or business


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com