FROM : Mike R. Manzano
DATE : Thu Aug 31 20:05:54 2006
Hi all,
Thanks for the replies thus far. I suppose I wasn't specific enough
with my question. Here's what seems to be fouling up my app:
(1) I start resizing my window.
(2) The window resize causes NSTextViews to resize in response.
(3) This forces the text within the text views to do a re-layout.
(4) In response to the re-layout, my delegates add/remove NSTextViews
to accommodate the new text layout.
It seems that somewhere in here things are getting all fouled up. The
NSTextViews don't render properly. Is what I'm doing bad?
I seemed to have gotten around this problem by:
(A) Having the subview that arranges the view not pay attention to
frame resizes, but instead a special notification that I post myself.
(2) Posting this special notification in the parent view's
viewDidEndLiveResize, and also in my window's zoom:.
(iii) For whatever reasons, views still seemed to get fouled up
until, in my layoutManager:didCompleteLayoutForTextContainer:atEnd:
delegate method, I deferred my NSTextView addition/removal thusly:
// [ self appendOneTextView ] ;
[ self performSelector:@selector( appendOneTextView )
withObject:nil afterDelay:0.0f ] ;
This seems to workn consistently, but:
(x) (obviously) live resize is now ugly, because my views don't
refresh until AFTER the live resize is finished
(x+1) I have no clue why I had to defer appendOneTextView, which
makes me uneasy.
I hope that wasn't too detailed. Any thoughts?
~ Mike
alephx01 (at) mac (dot) com
On Aug 30, 2006, at 9:58 PM, Andrew Merenbach wrote:
> Hi, Mike. In regard to (2), you may wish to do something like (in
> accordance with Uli's suggestion) in the class that handles the
> adding and removing of subviews:
>
> [[NSNotificationCenter defaultCenter] addObserver:self
> selector:@selector(addOrRemoveSubviewsDuringResize:)
> name:NSWindowDidResizeNotification object:myWindow];
>
> This will cause -addOrRemoveSubviewsDuringResize: to be called
> whenever the pixel dimensions of myWindow change. Change the
> observer if you need a different object to handle the adding or
> removing of subviews.
>
> Cheers,
> Andrew
>
> On Aug 30, 2006, at 1:56 PM, Uli Kusterer wrote:
>
>> Am 30.08.2006 um 20:40 schrieb Mike R. Manzano:
>>> (1) Is it prudent to add or remove subviews in drawRect:?
>>
>> No. Moving views can cause a view to be invalidated, which would
>> cause drawRect: to be called again. If you search the list
>> archives you'll se epostings from lots of people who did it anyway
>> and got hilarious endless loops, dropped updates and other odd
>> behaviour.
>>
>>> If not,
>>>
>>> (2) Is it prudent to add or remove views somewhere else during a
>>> window live resize?
>>
>> I think there's a notification sent when auto-resizing happens.
>> Alternatively, you could just override that method (don't remember
>> the name, but a quick read of NSView.h should make it obvious)
>> that's called when a superview is resized and asked to resize its
>> subviews. That should be a safe place to show/hide subviews before
>> calling through to super.
>>
>> Cheers,
>> -- M. Uli Kusterer
>> http://www.zathras.de
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Cocoa-dev mailing list (<email_removed>)
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/andrew.merenbach%
>> 40ucla.edu
>>
>> This email sent to andrew.<email_removed>
>
DATE : Thu Aug 31 20:05:54 2006
Hi all,
Thanks for the replies thus far. I suppose I wasn't specific enough
with my question. Here's what seems to be fouling up my app:
(1) I start resizing my window.
(2) The window resize causes NSTextViews to resize in response.
(3) This forces the text within the text views to do a re-layout.
(4) In response to the re-layout, my delegates add/remove NSTextViews
to accommodate the new text layout.
It seems that somewhere in here things are getting all fouled up. The
NSTextViews don't render properly. Is what I'm doing bad?
I seemed to have gotten around this problem by:
(A) Having the subview that arranges the view not pay attention to
frame resizes, but instead a special notification that I post myself.
(2) Posting this special notification in the parent view's
viewDidEndLiveResize, and also in my window's zoom:.
(iii) For whatever reasons, views still seemed to get fouled up
until, in my layoutManager:didCompleteLayoutForTextContainer:atEnd:
delegate method, I deferred my NSTextView addition/removal thusly:
// [ self appendOneTextView ] ;
[ self performSelector:@selector( appendOneTextView )
withObject:nil afterDelay:0.0f ] ;
This seems to workn consistently, but:
(x) (obviously) live resize is now ugly, because my views don't
refresh until AFTER the live resize is finished
(x+1) I have no clue why I had to defer appendOneTextView, which
makes me uneasy.
I hope that wasn't too detailed. Any thoughts?
~ Mike
alephx01 (at) mac (dot) com
On Aug 30, 2006, at 9:58 PM, Andrew Merenbach wrote:
> Hi, Mike. In regard to (2), you may wish to do something like (in
> accordance with Uli's suggestion) in the class that handles the
> adding and removing of subviews:
>
> [[NSNotificationCenter defaultCenter] addObserver:self
> selector:@selector(addOrRemoveSubviewsDuringResize:)
> name:NSWindowDidResizeNotification object:myWindow];
>
> This will cause -addOrRemoveSubviewsDuringResize: to be called
> whenever the pixel dimensions of myWindow change. Change the
> observer if you need a different object to handle the adding or
> removing of subviews.
>
> Cheers,
> Andrew
>
> On Aug 30, 2006, at 1:56 PM, Uli Kusterer wrote:
>
>> Am 30.08.2006 um 20:40 schrieb Mike R. Manzano:
>>> (1) Is it prudent to add or remove subviews in drawRect:?
>>
>> No. Moving views can cause a view to be invalidated, which would
>> cause drawRect: to be called again. If you search the list
>> archives you'll se epostings from lots of people who did it anyway
>> and got hilarious endless loops, dropped updates and other odd
>> behaviour.
>>
>>> If not,
>>>
>>> (2) Is it prudent to add or remove views somewhere else during a
>>> window live resize?
>>
>> I think there's a notification sent when auto-resizing happens.
>> Alternatively, you could just override that method (don't remember
>> the name, but a quick read of NSView.h should make it obvious)
>> that's called when a superview is resized and asked to resize its
>> subviews. That should be a safe place to show/hide subviews before
>> calling through to super.
>>
>> Cheers,
>> -- M. Uli Kusterer
>> http://www.zathras.de
>>
>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Cocoa-dev mailing list (<email_removed>)
>> Help/Unsubscribe/Update your Subscription:
>> http://lists.apple.com/mailman/options/cocoa-dev/andrew.merenbach%
>> 40ucla.edu
>>
>> This email sent to andrew.<email_removed>
>
| Related mails | Author | Date |
|---|---|---|
| Mike R. Manzano | Aug 30, 20:40 | |
| Uli Kusterer | Aug 30, 22:56 | |
| Andrew Merenbach | Aug 31, 06:58 | |
| Mike R. Manzano | Aug 31, 20:05 |






Cocoa mail archive

