DekGenius.com
[ Team LiB ] Previous Section Next Section

NSTextField Mac OS X 10.0

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.

figs/cocn_15106.gif

@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;
   - (void)setDrawsBackground:(BOOL)flag;
   - (BOOL)drawsBackground;
   - (void)setTextColor:(NSColor *)color;
   - (NSColor *)textColor;
   - (void)setEditable:(BOOL)flag;
 // Instance Methods
   - (BOOL)acceptsFirstResponder;
   - (BOOL)isBezeled;
   - (BOOL)isBordered;
   - (BOOL)isEditable;
   - (BOOL)isSelectable;
   - (void)selectText:(id)sender;
   - (void)textDidBeginEditing:(NSNotification *)notification;
   - (void)textDidChange:(NSNotification *)notification;
   - (void)textDidEndEditing:(NSNotification *)notification;
   - (BOOL)textShouldBeginEditing:(NSText *)textObject;
   - (BOOL)textShouldEndEditing:(NSText *)textObject;

Subclasses

NSComboBox, NSSecureTextField

    [ Team LiB ] Previous Section Next Section