RE: Subclassing NSTextView under Tiger
RE: Subclassing NSTextView under Tiger
- Subject: RE: Subclassing NSTextView under Tiger
- From: Keith Blount <email@hidden>
- Date: Tue, 9 Aug 2005 11:19:04 -0700 (PDT)
Just in case anyone else comes across the same issue,
I think I have solved this - after more testing, here
is what I found:
In Tiger,
-shouldChangeTextInRanges:replacementStrings: seems to
act as the primitive.
-shoulcChangeTextInRange:replacementString: (the
single selection method) appears to call the mutliple
method above.
Thus, in my NSTextView subclass, I have changed it so
that all my custom live word
count/smart-hyphens/smart-quotes code is done in the
new -shouldChangeTextInRanges:... method. That way it
all gets called no matter which method I call in my
code. This seems to work.
Thanks,
Keith
--- ORIGINAL POST ---
Hello,
I have an NSTextView subclass that deals with things
like image resizing, live word count,
auto-capitalisation, annotations etc. In order to
implement some of these features, I have overridden:
-shouldChangeTextInRange:replacementString:
However, under Tiger, with its support for multiple
text selections, a new equivalent method has been
introduced for multiple selections:
-shouldChangeTextInRanges:replacementStrings:
Does anybody know where my override code now belongs?
Currently I have left it in the original (single)
method, and it seems to be working. But even NSLogging
in the two methods I am a bit confused as to the
relationship between the two methods. I had assumed
that the multiple method would call the single method
multiple times, or that the single method would call
the multiple method once, but this does not seem to be
the case.
Do I need to put my code in both methods, or only in
one - and if so, which one? If anybody could clarify
how these methods work with one another, and how a
subclass should handle overriding them so as to avoid
any pitfalls, I would be very grateful.
Many thanks in advance,
Keith
____________________________________________________
Start your day with Yahoo! - make it your home page
http://www.yahoo.com/r/hs
_______________________________________________
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