• 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: Tweaking a window size
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tweaking a window size


  • Subject: Re: Tweaking a window size
  • From: "Michael Ash" <email@hidden>
  • Date: Tue, 30 Dec 2008 08:27:49 -0500

On Tue, Dec 30, 2008 at 1:48 AM, Graham Cox <email@hidden> wrote:
> One of my windows has a delegate implementing the -windowWillResize:toSize:
> method. This forces the window size to be certain whole multiples of rows in
> a matrix of icons, the idea being to prevent the user from sizing the window
> so that only a partial row is visible, which is ugly. It works as I wish.
>
> The user can also select whether they want small, medium or large icons in
> this matrix, so the row height changes as a result. When this happens I'd
> like to be able to tweak the window height as minimally as necessary to
> conform to the "whole rows" requirement.
>
> Since the delegate method already does all the needed calculation, I figured
> I could just do something that would cause it to get triggered just as if
> the user had dragged the resize widget. Unfortunately, -setFrame:display: is
> explicitly excluded in the docs - it doesn't call the delegate method - , so
> that's out. So I tried getting the saved frame string then setting the frame
> using the string, but while that should call the delegate, it appears not to
> if the size is the same as the window's current size.
>
> Any ideas how I can force the window to act as if it were being resized?

I think you're approaching this backwards. It's generally wrong to try
to tweak the guts of your app to trigger this sort of fixup response.
These delegate methods are intended to be in response to user actions.
For programmatic changes, it's assumed that your code knows what's
going on.

What you really want to do is to invoke your delegate method. So call
it! Delegate methods are not special. Something like this will do:

if([[window delegate] respondsToSelector:@selector(windowWillResize:toSize:)]) {
   NSRect frame = [window frame];
   frame.size = [[window delegate] windowWillResize:window toSize:frame.size];
   [window setFrame:frame display:YES];
}

Or better yet, have a separate method which generates the needed size,
and then call that method both from here and the -windowWillResize:
implementation.

Mike
_______________________________________________

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: Tweaking a window size [SOLVED]
      • From: Graham Cox <email@hidden>
References: 
 >Tweaking a window size (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Saving unseen NSView with subviews to NSImage
  • Next by Date: Re: Scrollwheel ignores line scroll setting in NSScrollView - bug?
  • Previous by thread: Tweaking a window size
  • Next by thread: Re: Tweaking a window size [SOLVED]
  • Index(es):
    • Date
    • Thread