• 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: Strategies for fitting an NSWindow to its content?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strategies for fitting an NSWindow to its content?


  • Subject: Re: Strategies for fitting an NSWindow to its content?
  • From: Ryan Stevens <email@hidden>
  • Date: Mon, 6 Oct 2003 23:26:48 -0700

On Monday, October 6, 2003, at 09:25 PM, Andrew Thompson wrote:

Hi all,

A puzzle with window resizing.

Usually Cocoa employs an outside-in model. ie, one sets the frame of one's NSWindow, and the views within it are resized according to their Autosize settings.

However, what if I want to go the other way and have an NSWindow grow and shrink as children of its content view change size?

The deal is I have a custom NSTextfield, which is one of several child views of the content view of an NSWindow.
I manipulate this NSTextField, and it uses -[sizeToFit] to alter its own size to grow or shrink to show its content.

However, if it gets bigger, it will be clipped by its containing NSWindow.

Is there any way for an NSWindow to consider its content view's children and realize that one has been resized such that its frame/bounds lie outside the visible portion of the NSWindow?

To complicate things a little further, sometimes I remove the content view in question from its parent window and put it elsewhere. It might resize whilst not in the window, which means when I put it back in the NSWindow, I might need to resize the window to be large enough to show the new content.

I'm really just looking for ideas here. I'd like this to happen automatically... I feel like there should be some way for an NSWindow custom subclass to monitor what's being resized within its content view and make sure its an appropriate size for everything to be visible.

Sounds good to me....

[textField setPostsFrameChangedNotifications: YES];
[textField setPostsBoundsChangedNotifications: YES]; // is this needed?

and in your NSWindow subclass just watch for a new frame, see if it's outside and resize as needed.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
References: 
 >Strategies for fitting an NSWindow to its content? (From: Andrew Thompson <email@hidden>)

  • Prev by Date: NSTask
  • Next by Date: launching 2 same applications
  • Previous by thread: Strategies for fitting an NSWindow to its content?
  • Next by thread: Re: Strategies for fitting an NSWindow to its content?
  • Index(es):
    • Date
    • Thread