Creating a NSTextField
-
Hello,
I am building Cocoa apps without the interface builder. Creating a
NSWindow instance is really easy, and I can do:
NSWindow* MainWindow = [[NSWindow alloc] initWithContentRect: MainWindowRect
styleMask: NSTitledWindowMask | NSClosableWindowMask |
NSMiniaturizableWindowMask | NSResizableWindowMask
backing: NSBackingStoreBuffered
defer: NO];
But there is no initialization method for a NSTextField. How can I
create a NSTextField? Just alloc?
thanks,
--
Felipe Monteiro de Carvalho -
On Feb 26, 2008, at 9:13 AM, Felipe Monteiro de Carvalho wrote:> But there is no initialization method for a NSTextField. How can I
> create a NSTextField? Just alloc?
Generally more like:
[[NSTextField alloc] initWithFrame:someRect];
Ken
--
Ken Worley
Software Engineer, Tiberius, Inc. -
On 2008 Feb, 26, at 8:13, Felipe Monteiro de Carvalho wrote:> But there is no initialization method for a NSTextField. How can I
> create a NSTextField? Just alloc?
NSTextField is a subclass of NSControl. Use [[NSTextView alloc] -
initWithFrame:].
Then use -addSubview: on your window's -contentView. And since your
NSTextView is not instantiated in Interface Builder, keep it in an
instance variable or something. -
>> But there is no initialization method for asince
>> NSTextField. How can I
>> create a NSTextField? Just alloc?
> NSTextField is a subclass of NSControl. Use
> [[NSTextView >alloc] - initWithFrame:]. Then use
> -addSubview: on your window's -contentView. And> your NSTextView is not instantiated in Interfacesomething.
> Builder, keep it in an instance variable or
And don't forget to -release it after you add it to
superview, since the latter retains it.
Looking for the perfect gift? Give the gift of Flickr!
http://www.flickr.com/gift/


