Re: Deleting contents of NSTextView...
Re: Deleting contents of NSTextView...
- Subject: Re: Deleting contents of NSTextView...
- From: Eric <email@hidden>
- Date: Tue, 02 Jul 2002 05:35:55 -0400
on 7/1/02 10:59 AM, Bill Cheeseman at email@hidden wrote:
>
on 02-06-30 10:10 PM, Sherm Pendley at email@hidden wrote:
>
>
> Still, it seems odd; one of the things that I find appealing about
>
> Cocoa, compared to Swing, MFC, GTK, etc., is its self-consistency.
>
> That's why it strikes me as odd that, while NSControl and NSCell (which
>
> doesn't inherit from NSControl) have setStringValue: methods, the NSText
>
> and NSString methods that serve the same purpose are called setString:
>
> instead.
>
>
Here's my (very tentative) take on this. I would welcome feedback because
>
I'm not really sure.
>
>
NSTextView isn't a control -- neither by inheritance nor in concept. For
>
example, it doesn't want to send an action method on end editing, according
>
to its Interface Builder Info Panel's Attributes pane, as controls do. Its
>
data should be updated on the fly as the user types, cuts, pastes, etc.,
>
using the textDidChange: delegate method as needed to keep the text view and
>
its data store synchronized. Not needing an action method or some other
>
explicit end-editing signal makes it possible to save the current contents
>
of the text view without requiring the user to give some signal that editing
>
is done. As I program an NSTextView in a window, I find myself taking a
>
completely different approach than I do with user controls.
I initially thought to implement an NSTextView in the same way (Your Vermont
Recipes was one of the first Cocoa tutorials I read, so I'm sure it heavily
influenced my thought process), however as I learn more about the Cocoa text
system, I wonder if there is a better way. Having a separate data store as
the text view's model object seems to be superfluous when Apple has already
provided you with a model class, namely NSTextStorage. Also, repeatedly
calling -textDidChange: in order to sychronize the text view with it's data
store whenever the user changes the contents of the text view seems somewhat
inefficient to me.
I hate to criticize your approach and not suggest a better alternative, but
I'm not really sure myself. I'm still trying to figure the Cocoa text system
out. Perhaps someone else could offer a better implementation.
Btw, Recipe 6 will be coming out soon, I hope :-)
Eric Wang
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.