Re: Subviews of a borderless window - autoresizing mask does not work for me
Re: Subviews of a borderless window - autoresizing mask does not work for me
- Subject: Re: Subviews of a borderless window - autoresizing mask does not work for me
- From: Cathy Shive <email@hidden>
- Date: Wed, 2 Apr 2008 18:13:07 +0200
Hi Hendrik,
It seems that you're using the correct mask. The documentation
states that NSViewMinYMargin would make the bottom margin flexible,
which is what you want.
I notice that you originally set the frame for the subview at (0,
0). Is this because the subview is originally the same size as the
window's content view? If not, you should calculate the proper
origin so that the subview is positioned exactly where you want in to
be in the window's content view before you set the autoresizing
mask. Also, make sure that your top margin isn't something strange.
If, for example, the top of the subview is beyond the top of the
window's content view when the mask is set, there will probably be
strange behavior with autoresizing. Double check your original
layout code so that the subview is without a doubt completely within
the frame of the superview.
Another long shot. Try using the plain -(void)addSubview method
instead of the one you're using. I'm not sure why this would effect
autoresizing except that it seems that it might be effecting the view
hierarchy in some way so maybe the superview isn't autoresizing that
view for some weird reason. Like I said, real long shot....
Good luck,
Cathy
On Apr 2, 2008, at 4:35 PM, Hendrik Holtmann wrote:
Hi,
I am creating a borderless window in source like this:
containerWindow = [[[ContainerWindow alloc]
initWithContentRect:NSMakeRect
(rect.origin.x,rect.origin.y-22-34,387,34)
styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered
defer:NO] retain];
Then I add a custom view (created in interface builder) as a
subview using the following code:
NSRect frame = [mySearchView bounds];
[mySearchView setFrame:NSMakeRect
(0.0,0,frame.size.width,frame.size.height)];
[[containerWindow contentView] addSubview:mySearchView positioned:1
relativeTo:nil];
[mySearchView setNeedsDisplay:YES];
That works fine. I want the customs subview position to be fixed
now, so when resizing occurs it does not change its position and
stays fixed to the upper left corner of the window.
Therefore I used
[[containerWindow contentView] setAutoresizesSubviews:YES];
[mySearchView setAutoresizingMask:NSViewMinYMargin];
According to the documentation this should be the right way to do
it (hopefully). Then I change the height of containerWindow in
source using:
NSRect frame = [containerWindow frame];
frame.size.height += 200;
frame.origin.y -= 200;
[containerWindow setFrame: frame display: YES animate: NO];
What happens now is that mySearchView moves to the buttom of the
window. What I would like to achieve is that its fixed to the top
of the window (left corner). Obviously the autoresizing mask does
not work here?
Did I miss something? any help would be appreciated!
Best,
Hendrik
_______________________________________________
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
_______________________________________________
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