Inherits From:
NSControl : NSView : NSResponder : NSObject
Conforms To:
NSCoding (NSResponder)
NSObject (NSObject)
Declared In:
AppKit/NSTextField.h
textShouldEndEditing:
. See the NSWindow and NSTextView class specifications for more information on a window's field editor.Typical of several kinds of control, NSTextField allows you to set its text and background color, whether it draws the background, and whether it draws a bezel or border around its text. Note that the text and background colors of selected text are configurable. The selected text color overshadows any actual text color applied to the text while it's selected (this is generally the case with controls).
You can link text fields together in their window's key view loop, as described in the NSWindow class specification.
acceptsFirstResponder
Returns YES if the receiver is editable or selectable, NO otherwise.
allowsEditingTextAttributes
Returns YES if the receiver allows the user to change font attributes of the receiver's text, NO if the user isn't permitted to do so. You can change text attributes programmatically regardless of this setting.
See also:
- importsGraphics
, - setAllowsEditingTextAttributes:
backgroundColor
Returns the color of the background that the receiver draws behind the text.
See also:
- drawsBackground
, - setBackgroundColor:
delegate
Returns the receiver's delegate.
See also:
- textShouldBeginEditing:
, - textShouldEndEditing:
, - textDidBeginEditing:
,
- textDidEndEditing:
, - textDidChange:
, - setDelegate:
drawsBackground
Returns YES if the receiver's cell draws its background color behind its text, NO if it draws no background.
See also:
- backgroundColor
, - drawsBackground
(NSTextFieldCell), - setDrawsBackground:
errorAction
Returns the selector for the message sent to the receiver's target whenever a validation error occurs.
See also:
- textShouldEndEditing:
, - setErrorAction:
importsGraphics
Returns YES if the receiver allows the user to drag image files into it, NO if it doesn't accept dragged images. You can add images programmatically regardless of this setting.
See also:
- allowsEditingTextAttributes
, - importsGraphics
(NSTextView), - setImportsGraphics:
isBezeled
Returns YES if the receiver draws a bezeled frame around its contents, NO if it doesn't.
See also:
- isBordered
, - setBezeled:
isBordered
Returns YES if the receiver draws a solid black border around its contents, NO if it doesn't.
See also:
- isBezeled
, - setBordered:
isEditable
Returns YES if the user is allowed to select and edit the receiver's text, NO if the user isn't allowed to edit it (though the user may be able to select it).
See also:
- isSelectable
, - setEditable:
isSelectable
Returns YES if the user is allowed to select the receiver's text, NO if the user isn't allowed to select it. Selectable text isn't necessarily editable; use isEditable
to check for editability.
See also:
- setSelectable:
nextText
Returns the receiver's next key view, the object that's made first responder when the user presses the Tab key while editing the receiver. See the description of the nextKeyView
method in NSView for more information.
See also:
- previousText
, - setNextText:
previousText
Returns the receiver's previous key view, the object that's made first responder when the user presses Shift-Tab while editing the receiver. See the description of the previousKeyView
method in NSView for more information.
See also:
- nextText
, - setPreviousText:
selectText:
(id)sender
Selects the entire contents of the receiver if it's selectable. However, if the receiver isn't in some window's view hierarchy, this method has no effect.
See also:
- isSelectable
setAllowsEditingTextAttributes:
(BOOL)flag
Controls whether the receiver allows the user to change font attributes of the receiver's text. If flag is YES, the user is permitted to make such changes; if flag is NO, the user isn't so permitted. You can change text attributes programmatically regardless of this setting.
See also:
- setImportsGraphics:
, - allowsEditingTextAttributes
setBackgroundColor:
(NSColor *)aColor
Sets the color of the background that the receiver draws behind the text to aColor.
See also:
- setDrawsBackground:
, - backgroundColor
setBezeled:
(BOOL)flag
Controls whether the receiver draws a bezeled border around its contents. If flag is NO, it draws no border; if flag is YES, it draws a bezeled border and invokes setDrawsBackground:
with an argument of NO.
See also:
- isBezeled
, - setBordered:
setBordered:
(BOOL)flag
Controls whether the receiver draws a solid black border around its contents. If flag is YES, then it draws a border; if flag is NO, it draws no border.
See also:
- isBordered
, - setBezeled:
setDelegate:
(id)anObject
Sets the receiver's delegate to anObject.
See also:
- textShouldBeginEditing:
, - textShouldEndEditing:
, - textDidBeginEditing:
,
- textDidEndEditing:
, - textDidChange:
, - delegate
setDrawsBackground:
(BOOL)flag
Controls whether the receiver draws its background color behind its text. If flag is YES, then it does; if flag is NO, then it draws nothing behind its text.
See also:
- setBackgroundColor:
, - setDrawsBackground:
(NSTextFieldCell), - drawsBackground
setEditable:
(BOOL)flag
Controls whether the user can edits the receiver's text. If flag is YES, then the user is allowed to both select and edit text. If flag is NO, then the user isn't permitted to edit text, and the receiver's selectability is restored to its previous value. For example, if an NSTextField is selectable but not editable, then made editable for a time, then made not editable, it remains selectable. To guarantee that text is neither editable nor selectable, simply use setSelectable:
to turn off selectability.
See also:
- isEditable
setErrorAction:
(SEL)aSelector
Sets the selector for the message sent to the receiver's target whenever a validation error occurs to aSelector.
See also:
- textShouldEndEditing:
, - errorAction
setImportsGraphics:
(BOOL)flag
Controls whether the receiver allows the user to drag image files into it. If flag is YES, the receiver accepts dragged images; if flag is NO, it doesn't. You can add images programmatically regardless of this setting.
See also:
- setAllowsEditingTextAttributes:
, - setImportsGraphics:
(NSTextView), - importsGraphics
setNextText:
(id)anObject
Sets the receiver's next key view to anObject, which should be a kind of NSView. See the description of the setNextKeyView:
method in the NSView class specification for more information.
See also:
- setPreviousText:
, - nextText
setPreviousText:
(id)anObject
Sets the receiver's previous key view to anObject, which should be a kind of NSView. See the description of the setPreviousKeyView:
method in the NSView class specification for more information.
See also:
- setNextText:
, - previousText
setSelectable:
(BOOL)flag
If flag is YES, the receiver is made selectable but not editable (use setEditable:
to make text both selectable and editable). If NO, then the text is made neither editable nor selectable.
See also:
- setEditable:
setTextColor:
(NSColor *)aColor
Sets the color used to draw the receiver's text to aColor.
See also:
- setBackgroundColor:
, - setTextColor:
(NSTextFieldCell), - textColor
setTitleWithMnemonic:
(NSString *)aString
Sets the receiver's string value to aString, using the first character preceded by an ampersand (`&') as the mnemonic and stripping out that first ampersand character. Use this method only with a non-editable text field being used as a label for another interface component, which you should establish using setNextKeyView:
. When set up in this fashion, the text field's mnemonic serves to select the other interface component.
textColor
Returns the color used to draw the receiver's text.
See also:
- backgroundColor
, - textColor
(NSTextFieldCell), - setTextColor:
textDidBeginEditing:
(NSNotification *)aNotification
Posts an NSControlTextDidBeginEditingNotification to the default notification center. This causes the receiver's delegate to receive a controlTextDidBeginEditing:
message. See the NSControl class specification for more information on the text delegate method.
See also:
- textDidBeginEditing:
, - textDidChange:
, - textShouldEndEditing:
, - textDidEndEditing:
textDidChange:
(NSNotification *)aNotification
Forwards this message to the receiver's cell if it responds, and posts an NSControlTextDidChangeNotification to the default notification center. This causes the receiver's delegate to receive a controlTextDidChange:
message. See the NSControl class specification for more information on the text delegate method.
See also:
- textShouldBeginEditing:
, - textDidBeginEditing:
, - textShouldEndEditing:
,
- textDidEndEditing:
textDidEndEditing:
(NSNotification *)aNotification
Handles an end to editing. After validating the new value, posts an NSControlTextDidEndEditingNotification to the default notification center. This causes the receiver's delegate to receive a controlTextDidEndEditing:
message. After this, sends endEditing:
to the receiver' cell, and handles the key that caused editing to end:
performKeyEquivalent:
to its NSWindow (for example, to handle the default button on a panel); if that also fails, then the receiver simply selects its text.
selectKeyViewFollowingView:
or selectKeyViewPreceedingView:
. If unsuccessful in doing this, the receiver simply selects its text.
See also:
- textShouldBeginEditing:
, - textDidBeginEditing:
, - textDidChange:
,
- textShouldEndEditing:
textShouldBeginEditing:
(NSText *)textObject
If the receiver isn't editable, returns NO immediately. If it is editable and its delegate responds to control:textShouldBeginEditing:
, invokes that method and returns the result. Otherwise simply returns YES to allow editing to occur. See the NSControl class specification for more information on the text delegate method.
See also:
- textDidBeginEditing:
, - textDidChange:
, - textShouldEndEditing:
, - textDidEndEditing:
textShouldEndEditing:
(NSText *)textObject
Performs validation on the receiver's new value using NSCell's isEntryAcceptable:
, sending the receiver's error action to its target if validation fails. If the new value is valid and the delegate responds to control:textShouldEndEditing:
, invokes that method and returns the result, in addition beeping if the delegate returns NO. See the NSControl class specification for more information on the text delegate method.
See also:
- textShouldBeginEditing:
, - textDidBeginEditing:
, - textDidChange:
,
- textDidEndEditing:
, - errorAction