Re: NSTextField: newbie answer and questions
Re: NSTextField: newbie answer and questions
- Subject: Re: NSTextField: newbie answer and questions
- From: Ondra Cada <email@hidden>
- Date: Thu, 8 Aug 2002 02:17:47 +0200
On Thursday, August 8, 2002, at 01:13 , ber wrote:
I started writing obj-c and using cocoa this past weekend so I guess
I'm not a newbie anymore.
Right!
Let's see if I can answer the question:
Precisely ;)
Now a couple questions I meant to ask when I was a newbie:
1) What's NS stand for - NextStep?
Yeah.
How about "nib", NextStep Interface
Block"?
NeXT Interface Builder
Does the "m" in the ".m" file extension of obj-c stand for
something?
Module
2) In Interface Builder I can add an NSTextField and by default it
doesn't show a background
box and I can make it Scrollable. I can't seem to get this
behavior programatically. If I try to make one
I created programatically Scrollable I get the message.
MyObject.m:32: warning: `NSTextField' does not respond to
`setScrollable:'
Yup. For some reason or another (probably just overlooked, but I don't
actually know) the text field does not forward this message to its cell.
You have to DIY:
[[textfield cell] setScrollable:YES]
NSTextField doesn't complain about "setDrawBackground: NO" but it
doesn't seem to have an effect.
I still get a white box behind my text.
Hmmm, strange. Let me check... well, I think I know what you stumbled over.
There are three potential hurdles, any of which might be the problem:
(a) so as the change shows, you might need to use [textfield
setNeedsDisplay:YES];
(b) so as the background can be not drawn, the field has to be borderless;
(c) and, at the moment the field should not be active (focused).
The (a) and (b) should be self-explaining. As for (c), the thing is that a
focused textfield (just like a table cell or, for that matter, any
editable cell) is no more a textfield, but an NSTextView. See the "field
editor" stuff of NSWindow.
Clearly I'm fuzzy on the relationship between NSTextField and NSCell
which seems to embody the methods
Well, its documented somewhere. Generally views which might contain a
number of "atomic displayers/editors" (like a browser does, eg). These
atomic things are cells. NSTextField looks somewhat strange since it has
just one cell, and thus raises questions like "why there is the
distinction at all". It's there to be consistent with matrices, browsers,
and whatever other controls, which contain many cells.
(Another question might be why all those browsers etc. don't contain just
NSTextFields instead. The answer is efficiency -- a cell is much more
lightweight than a view).
I would like to create an NSTextField, scrollable, with no background
just as IB can,
but programatically.
@implementation Controller
-(void)awakeFromNib {
[[textfield cell] setScrollable:YES];
[textfield setBordered:NO];
[textfield setDrawsBackground:NO];
}
In this case you don't even need to worry about displaying or focus --
awakeFromNib is early enough that neither is problem.
---
Ondra Cada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.