• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Subviews of a borderless window - autoresizing mask does not work for me
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Subviews of a borderless window - autoresizing mask does not work for me
      • From: Nate Weaver <email@hidden>
References: 
 >Subviews of a borderless window - autoresizing mask does not work for me (From: Hendrik Holtmann <email@hidden>)

  • Prev by Date: Re: Problem with Grouping the rotated object.
  • Next by Date: Re: How to store NSRect as Core Data attribute?
  • Previous by thread: Re: Subviews of a borderless window - autoresizing mask does not work for me
  • Next by thread: Re: Subviews of a borderless window - autoresizing mask does not work for me
  • Index(es):
    • Date
    • Thread