Re: NSPanel doesn't reposition correctly after screen resize
Re: NSPanel doesn't reposition correctly after screen resize
- Subject: Re: NSPanel doesn't reposition correctly after screen resize
- From: Kyle Sluder <email@hidden>
- Date: Tue, 03 Sep 2013 10:16:23 -0700
On Sep 3, 2013, at 9:28 AM, Keary Suska <email@hidden> wrote:
> On Sep 3, 2013, at 9:27 AM, Steve Mills wrote:
>
>> We have an NSPanel that doesn't stay stuck to the menubar if you make the screen bigger. If you make the screen smaller, it goes through constrainFrameRect:toScreen and does the right thing. In the nib, the window has the strut set between the screen and window top, and nothing set on the bottom. What's wrong with this thing? It's as if it's stuck to the bottom of the screen instead of the top, and no user thinks that way.
>
>
> Are you simply complaining out loud, or are you unfamiliar with the Cocoa drawing system? If it is the latter, all things will be made clear by reading this doc:
Except Steve is right that no user thinks that way, _AND_ he set up the window positioning struts in a way that indicates to him that the window should remain fixed relative to the top edge of the screen.
But that’s not what those struts are for. They determine position of the window when it first appears on screen, relative to the position defined in the nib. They don't affect the positioning behavior of the window if the screen resizes.
It used to be that windows in Interface Builder were top-level windows on the desktop, rather than drawn on a canvas. The position of the window on screen at design time was encoded in the nib, and that position is where the window would appear by default when the window was unarchived from nib. (It was also a lot more common for windows to be “visible at launch,” especially since NSWindowController didn’t exist.)
At some point the springs and struts were added because enough users had differently-sized desktops. The position encoded in nib would be scaled according to the struts. So you could center a window on your screen, unhinge it from all four edges, and the window would appear centered on all your users’s screens.
Nowadays, you draw the window on a canvas, so you specify the position of the window by dragging the window proxy in the inspector.
Long story short, Steve, the struts aren’t as useful as you think they are. If you're already using a custom view in your status items, you can get the behavior you want by sending -window to the custom view during mouse tracking, and adding your popup window as a child window.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden