O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

NSTextField — Mac OS X 10.0

Synopsis

This control class implements an editable text entry and display field. NSTextField’s companion cell class is NSTextFieldCell, a subclass of NSActionCell. Thus, NSTextField is capable of sending action messages to targets. By default, actions are sent to targets when the user completes editing by pressing the Return key.

Accessing the value of a text field is done using methods inherited from NSControl (indeed, these are the methods used to access the values of any control). To get the contents of the text field as a string, invoke stringValue. Alternatively, we may take the value as a number using intValue, floatValue, and doubleValue. Each of these methods has a corresponding set... method used to change the value displayed in the text field. See NSControl (earlier in this chapter) for more information.

image with no caption

@interface NSTextField : NSControl
                                  // Accessor Methods
   - (void)setDelegate:(id)anObject;
   - (id)delegate;
   - (void)setImportsGraphics:(BOOL)flag;
   - (BOOL)importsGraphics;
   - (void)setSelectable:(BOOL)flag;
   - (void)setBordered:(BOOL)flag;
   - (void)setBezeled:(BOOL)flag;
   - (void)setAllowsEditingTextAttributes:(BOOL)flag;
   - (BOOL)allowsEditingTextAttributes;
   - (void)setBackgroundColor:(NSColor *)color;
   - (NSColor *)backgroundColor;
   - (void)setBezelStyle:(NSTextFieldBezelStyle)style;
   - (NSTextFieldBezelStyle)bezelStyle ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required