Re: NSTextView actions
Re: NSTextView actions
- Subject: Re: NSTextView actions
- From: "Michael Ash" <email@hidden>
- Date: Fri, 31 Oct 2008 14:48:46 -0400
On Thu, Oct 30, 2008 at 9:23 PM, Randall Meadows <email@hidden> wrote:
> OK, last text-related question of the day (I promise, only because I'm
> calling it a day after I send this)...
>
> I have an NSTextView, in an NSScrollView, (loaded from a nib) that I embed
> in a custom view at runtime; I also draw a reflection of that custom view.
>
> I figured out how to do a "live" reflection, where the reflection updates in
> real-time as the scroll bar is dragged around. However, it's only a partial
> solution, and while it works (partially), it's butt-ugly, and I'm guessing
> there must be a more elegant way to do this than what I'm doing.
>
> To do the live-drag reflection, I cache the original target/action of the
> scroller, and stuff my own target/action into it instead.
[snip]
Looks like you're trying to hook into everything that could possibly
cause the text view to redraw so that you can update your cache. But
this is bad, because you have to be 100% comprehensive or else it
falls apart. As you've noticed.
So rather than this, just get notified when the text view *actually*
redraws. There's no built-in way to do this (that I can think of right
now), but it's easy with a simple subclass. Subclass NSTextView, and
override -viewWillDraw, and have your override do whatever
notification you need.
Note that this requires 10.5. On 10.4 and under, you should be able to
accomplish the same thing with a -drawRect: override.
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