NSTextView in an NSToolbarItem - encoding problem
NSTextView in an NSToolbarItem - encoding problem
- Subject: NSTextView in an NSToolbarItem - encoding problem
- From: David Haas <email@hidden>
- Date: Fri, 2 Aug 2002 13:46:13 -0500
Hi. Hopefully somebody can give me a hand with this. And sorry if
you've read
this message in a different forum - I'm trying to ask as many people as
possible :)
I have a subclass of NSTextView as the document view of a NSScrollView,
which is a subview of
yet another view, located in a toolbar item of a window. It works just
fine in the toolbar,
but I've got problems when trying to run the toolbar customization
palette. In other words,
the customization palette doesn't appear, and I get a console message
telling me that
I've got NSCoding problems.
Since NSTextViews explicitly don't support NSCoding, I've got to make up
my own
initWithCoder & encodeWithCoder functions. As a first crack at this, I
made these
functions in my NSTextView subclass dirt simple . . .
- (id)initWithCoder:(NSCoder *)coder
{
self = [super initWithFrame:NSMakeRect(0,0,100,16)];
[self setString:@"hello"];
}
- (void)encodeWithCoder:(NSCoder *)coder
{
return;
}
So, this works - sort of. The customization palette appears, and I can
reorder
my toolbar at will. The problem is the NSTextView in the customization
palette
is not a subview of my scrollview. So then my scrollview (which had no
color) looks
like the window background (which looks funny in the view it's a subview
of), and I've
got a white square with the word "Hello" written in the bottom left
corner of the palette.
The subclass doesn't implement initWithFrame - it's just calling
NSTextView's. When
I check for the presence of a superview in initWithCoder, there isn't
one (no surprise,
I guess). If I try to setAutoresizingMask to make it autoscale to the
width & height of
it's superview, it doesn't show up at all. The only place this class
was ever made a
subview of the scroll view was in IB, so I've got no code written to
correctly smush
stuff together in the proper hierarchy.
I've played around with the -replacementObjectForCoder and
-awakeAfterUsingCoder,
trying to replace the object with just a plain NSView for coding
purposes & then
reconstructing my TextView subclass after it's woken up - but the view
wasn't ending
up as a subview of the scrollview either, so that got me nowhere.
I don't really care what actually appears in the customization palette
for this item - if
I could make an image & just substitute that for the actual view here,
I'd be content
(and I think I read that technique is used in omniweb, so I could
probably dig up
some example code, although I wouldn't mind a point in the right
direction).
But, for my own understanding, I'd like to figure out how this "should"
be set up to
make the NSTextView appear in the appropriate place of my toolbar item
image.
If someone could help me out, I'd really appreciate it.
Thanks.
David Haas
_______________________________________________
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.