Displaying at appropriate time after text layout...?
Displaying at appropriate time after text layout...?
- Subject: Displaying at appropriate time after text layout...?
- From: Keith Blount <email@hidden>
- Date: Sun, 9 Mar 2008 13:42:26 -0700 (PDT)
Hello,
I have a multiple-page text view, much like the one in TextEdit, except that mine has a custom clip view that draws a shadow around the view it contains and the page view gets different text storages swapped in and out of it (using NSTextStorage's -addLayoutManager:). All of which makes it a little more complicated, of course.
Any way, I have a really odd (to me) problem with the display not getting updated properly. Basically, when text gets added to my multiple page view, an -addPage: method gets called from the NSLayoutManager delegate method, -layoutManager:didCompleteLayoutForTextContainer:atEnd:, all exactly the same as in TextEdit. At this point, obviously, the frame gets recalculated, -setNeedsDisplay: gets called, and also, I post a notification that the page number has changed and use -setStringValue: on an NSTextField that displays the number of pages.
The -drawRect: method of my pages view deals with drawing the page backgrounds, and, as I say, my custom clip view (NSClipView subclass) deals with drawing a shadow around its document view as an extra visual touch.
The problem, however, is that sometimes the display only seems to get updated for the first page - so that even though there may be two or three pages (or more) present - with the frame set accordingly - the background only draws one page, the clip view only draws the shadow around the document frame as it was when the multiple page view only had one page, and my text field only displays "1 page". If I NSLog just before and after -setStringValue: on my text field, it shows that the value I am setting is correct, it is just that the text field is not getting updated. Obviously, I can call -display on the text field (-setNeedsDisplay: does nothing in this situation, for some reason), but I can't do the same for my multiple text view, as that reeks havoc with the layout and can cause more pages than necessary to be laid out.
In short, I can't find exactly where I need to call either -display or -setNeedsDisplay: without causing redrawing problems (where I have called -display successfully, it has thickened the text as though it is being drawn twice).
If anyone has any ideas about what I might be doing wrong here, or why the display might not get updated properly in this situation, I would be very grateful. What is really odd is that the frame is getting set accordingly, which should really cause the clip view to redraw, and my frame recalculation methods also call -setNeedDisplay: on the multi-page view - but all with no effect.
Thanks in advance and all the best,
Keith
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
_______________________________________________
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