Re: Subclassing NSTextView

2008-08-13 Thread Michael Ash
On Tue, Aug 12, 2008 at 9:15 PM, John Joyce
<[EMAIL PROTECTED]> wrote:
> Ooops, nevermind!!
> I answered my own question.
> When adding the class file to the project, start with the NSView subclass
> template, then change it to subclass NSTextView in the .h
> and in the .m either call [super drawRect:rect]; or comment out or delete
> the drawRect method all together.
> That was too stupidly easy to be obvious.
> Too bad there is not an option for more subclass templates right in the GUI

In most cases, all you need to create a minimal, functional subclass is this:

@interface MyClass : SuperClass {} @end
@implementation MyClass @end

In other words, just a plain empty class with no methods and no ivars,
inheriting from the class you want.

This is all due to the idea of OO programming. You inherit all of the
behavior of the superclass. If you provide no further behavior, then
you act exactly like that superclass.

There is one big exception to this. If the superclass is actually an
abstract class with private concrete subclasses (which is to say that
doesn't implement all of its functionality on its own) then there will
be required functionality that any subclass must implement. In Cocoa
these are generally called class clusters, documented as such, and the
required subclass functionality listed (the required methods are
called primitive methods).

It's unlikely for an NSView to be a class cluster (it's *possible*,
but I know of no examples of such) so for any NSView you subclass, you
can just start with a blank slate as above.

Mike
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Subclassing NSTextView

2008-08-12 Thread Graham Cox


On 13 Aug 2008, at 11:15 am, John Joyce wrote:

Too bad there is not an option for more subclass templates right in  
the GUI ...



There is.

Just create the files you want to use as templates and store them at:

/Developer/Library/Xcode/Cocoa/.pbfiletemplate/ 
class.


You also need a plist to describe the template to Xcode. More info here:

http://www.macresearch.org/custom_xcode_templates


hth,

Graham
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


RE: Subclassing NSTextView

2008-08-12 Thread John Joyce

Ooops, nevermind!!
I answered my own question.
When adding the class file to the project, start with the NSView  
subclass template, then change it to subclass NSTextView in the .h
and in the .m either call [super drawRect:rect]; or comment out or  
delete the drawRect method all together.

That was too stupidly easy to be obvious.
Too bad there is not an option for more subclass templates right in  
the GUI ...

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Subclassing NSTextView

2008-08-12 Thread John Joyce
In Xcode 3.1, what is the minimum necessary to create a useable  
subclass of NSTextView ?

(before adding/overriding methods)
Additionally, in IB, is there any effective difference from using an  
NSTextView, selecting the text view within its scroll view and  
changing its class (in the inspector) to that of the subclass (say,  
MyTextView, for example) and selecting a custom view, setting its  
class to MyTextView and then selecting Layout > Embed Objects In >  
Scroll View ?


I'm aware of the usual caveats leaning toward delegation and  
notification, but I'd like to do this as an exercise to better  
understand the capabilities of subclassing NSTextView.


Even a link to a tutorial/walk through would be nice.

I've already read
Subclassing NSTextView
in the developer docs, but it does not quite show me everything, it  
seems.


In the feeble attempts I've made, when running the app, the custom  
text view places vertical lines where glyphs would be, and it does so  
starting at wherever in the view you initially click...



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]