Re: windowWillResize:toSize: and windowDidResize: are not paired
Re: windowWillResize:toSize: and windowDidResize: are not paired
- Subject: Re: windowWillResize:toSize: and windowDidResize: are not paired
- From: Ricky Sharp <email@hidden>
- Date: Wed, 9 Mar 2005 16:48:01 -0600
On Mar 9, 2005, at 4:24 PM, Sean McBride wrote:
I have a window where I need to do some special handling of resizing.
A
(simplified) example: if I widen the window by 50 pixels, I need to
widen
one view by 20 and another by 30.
I am using windowWillResize:toSize: and windowDidResize: and it works
fairly well except that these two notifications do not always come in
pairs (for example if I zoom the window).
The only reason I need windowWillResize: is to know by how much the
window will resize. I store that info in my object instance and use it
in windowDidResize:.
It seems that if I'm in windowDidResize: I know that the window resized
but I have no way to know by how much. Is that so? If there was a way
to know at that point, I could adjust my 2 views then and I'd be fine.
Since you're already storing the window size in your object, just
initialize it to whatever your window size is when the window is first
created.
Remove your handler for windowWillResize and inside of windowDidResize,
do something like this:
* obtain new size from the given notification's object (the NSWindow)
* obtain old size and resize your views accordingly
* set the old size to the new size
You may want to consider putting this logic in a separate method. That
way, if you have code where you programatically set the window's size,
you can call this common method.
I do have to ask though why you're not setting up your views to be
automatically resized. Was that not possible to do for your situation?
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden