Re: Custom View drawn twice?
Re: Custom View drawn twice?
- Subject: Re: Custom View drawn twice?
- From: Ben Lachman <email@hidden>
- Date: Fri, 14 Mar 2008 13:13:04 -0400
On Mar 14, 2008, at 8:54 AM, Uli Kusterer wrote:
Oh great, so this message *did* get through even though I canceled
and it didn't get saved to my outbox...
Anyway, of course your "toggle" prevents the endless loop, but
it's still an ugly hack. Not to mention a bad way to name such a
variable. So, why exactly do you have a subview in a text view, and
why aren't you a text attachment or something similar? And isn't
there a better place to call display than drawRect:? Have you made
sure your text view and your image view and any of the partially
transparent views in between are not marked opaque like Ken Ferry
suggested? Or if you want some of them to be opaque, have you made
sure they actually erase their background appropriately?
I realize that it's an ugly hack. If I could find a way to remove
that code without completely restructuring my view hierarchy again
and rewriting huge chunks of my code, I'd do it. However I've been
through every call to setNeedsDisplay, looked at every view's
opaqueness, done my best to create a sample app and subclassed each
view in the hierarchy to look at when they're being drawn and set
needing display, etc. and I haven't been able to find a solution
other than never calling setNeedsDisplay... on the textview which
isn't really an option since the textview does need displayed at
times. At this point I've probably spent a full week debugging this
this issue and I don't really have much more time for it. Which
leads me to the fact that if this works, while I know I shouldn't
need to do things this way, I need to use it for the time being.
I really think you're just going about this the wrong way. What
exactly are you trying to do in a high-level way? Are you trying to
do text layout that flows around an image? Are you trying to show
text behind an image? Are you trying to embed a picture in an image?
The high-level task I'm trying to accomplish is a rotated image view
with a drop shadow in the top right corner of my text view that
selection and text flow around. I can't use a text attachment
because I need to support several bindings on the image view as well
as other subviews. My solution for this is to use a custom text
container to control the flow of the text and selection around the
area where the subview is laid out. If anyone has a better way of
doing this I'd love to hear it. I haven't been amazingly pleased
with this approach as it obviously has been less than headache free.
A more important point perhaps is that I don't really see why a text
view can't have a subview. It seems that it should behave like any
other view in the view hierarchy that is given a subview--it displays
itself and then its children, handles first responder and various
other things. And if it is the case that an NSTextView is some kind
of "leaf" view that can't have any child views then it should
probably be documented as such. FTW, are there any other views that
can't viably have children?
Thanks for the thoughts,
->Ben
_______________________________________________
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