Inherits from: NSControl : NSView : NSResponder : NSObject
Package: com.apple.yellow.application
An NSTextField is a kind of NSControl that displays text that the user can select or edit, and which sends its action message to its target when the user presses the Return key while editing. Like other controls, it also performs validation on its value when edited; if the value isn't valid it sends a special error action message to its target. An NSTextField can be assigned a delegate, who is then informed of delegate messages sent by the window's field editor, such as 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.
- Controlling editability and selectability
- setEditable
- isEditable
- setSelectable
- isSelectable
- Setting the error action
- setErrorAction
- errorAction
- Controlling rich text behavior
- setAllowsEditingTextAttributes
- allowsEditingTextAttributes
- setImportsGraphics:
- importsGraphics
- Setting the text color
- setTextColor
- textColor
- Controlling the background
- setBackgroundColor
- backgroundColor
- setDrawsBackground
- drawsBackground
- Setting a border
- setBezeled
- isBezeled
- setBordered
- isBordered
- Linking text fields together
- setNextText
- nextText
- setPreviousText
- previousText
- Selecting the text
- selectText
- Working with the responder chain
- acceptsFirstResponder
- Using keyboard interface control
- setTitleWithMnemonic
- Setting the delegate
- setDelegate
- delegate
- Text delegate methods
- textShouldBeginEditing
- textDidBeginEditing
- textDidChange
- textShouldEndEditing:
- textDidEndEditing
public NSTextField(NSRect frameRect)
public boolean acceptsFirstResponder()
true
if
the receiver is editable or selectable, false
otherwise.public boolean allowsEditingTextAttributes()
true
if
the receiver allows the user to change font attributes of the receiver's
text, false
if the user isn't permitted
to do so. You can change text attributes programmatically
regardless of this setting.See Also: importsGraphics, setAllowsEditingTextAttributes
public NSColor backgroundColor()
See Also: drawsBackground, setBackgroundColor
public Object delegate()
See Also: textShouldBeginEditing, textShouldEndEditing:, textDidBeginEditing, textDidEndEditing, textDidChange, setDelegate
public boolean drawsBackground()
true
if
the receiver's cell draws its background color behind its text, false
if
it draws no background.See Also: backgroundColor, - drawsBackground (NSTextFieldCell), setDrawsBackground
public NSSelector errorAction()
See Also: textShouldEndEditing:, setErrorAction
public boolean importsGraphics()
true
if
the receiver allows the user to drag image files into it, false
if it
doesn't accept dragged images. You can add images
programmatically regardless of this setting.See Also: allowsEditingTextAttributes, - importsGraphics (NSTextView), setImportsGraphics:
public boolean isBezeled()
true
if
the receiver draws a bezeled frame around its contents, false
if
it doesn't.See Also: isBordered, setBezeled
public boolean isBordered()
true
if
the receiver draws a solid black border around its contents, false
if
it doesn't.See Also: isBezeled, setBordered
public boolean isEditable()
true
if
the user is allowed to select and edit the receiver's text, false
if
the user isn't allowed to edit it (though the user may be able
to select it).See Also: isSelectable, setEditable
public boolean isSelectable()
true
if
the user is allowed to select the receiver's text, false
if
the user isn't allowed to select it. Selectable
text isn't necessarily editable; use isEditable to check for editability.See Also: setSelectable
public Object nextText()
See Also: previousText, setNextText
public Object previousText()
See Also: nextText, setPreviousText
public void selectText(Object sender)
See Also: isSelectable
public void setAllowsEditingTextAttributes(boolean flag)
true
,
the user is permitted to make such changes; if flag is false
,
the user isn't so permitted. You can change text attributes programmatically
regardless of this setting.See Also: setImportsGraphics:, allowsEditingTextAttributes
public void setBackgroundColor(NSColor aColor)
See Also: setDrawsBackground, backgroundColor
public void setBezeled(boolean flag)
false
,
it draws no border; if flag is true
,
it draws a bezeled border and invokes setDrawsBackground with an argument
of false
.See Also: isBezeled, setBordered
public void setBordered(boolean flag)
true
,
then it draws a border; if flag is false
,
it draws no border.See Also: isBordered, setBezeled
public void setDelegate(Object anObject)
See Also: textShouldBeginEditing, textShouldEndEditing:, textDidBeginEditing, textDidEndEditing, textDidChange, delegate
public void setDrawsBackground(boolean flag)
true
,
then it does; if flag is false
,
then it draws nothing behind its text.See Also: setBackgroundColor, - setDrawsBackground: (NSTextFieldCell), drawsBackground
public void setEditable(boolean flag)
true
,
then the user is allowed to both select and edit text. If flag is false
,
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
public void setErrorAction(NSSelector aNSSelector)
See Also: textShouldEndEditing:, errorAction
public void setImportsGraphics(boolean flag)
true
,
the receiver accepts dragged images; if flag is false
,
it doesn't. You can add images programmatically regardless of
this setting.See Also: setAllowsEditingTextAttributes, - setiImportsGraphics: (NSTextView), importsGraphics
public void setNextText(Object anObject)
- (void)setNextText:(id)anObject
See Also: setPreviousText, nextText
public void setPreviousText(Object anObject)
See Also: setNextText, previousText
public void setSelectable(boolean flag)
true
,
the receiver is made selectable but not editable (use setEditable to make
text both selectable and editable). If false
,
then the text is made neither editable nor selectable.See Also: setEditable
public void setTextColor(NSColor aColor)
See Also: setBackgroundColor, - setTextColor: (NSTextFieldCell), textColor
public void setTitleWithMnemonic(String aString)
public NSColor textColor()
See Also: backgroundColor, - textColor (NSTextFieldCell), setTextColor
public void textDidBeginEditing(NSNotification aNSNotification)
See Also: textDidBeginEditing, textDidChange, textShouldEndEditing:, textDidEndEditing
public void textDidChange(NSNotification aNotification)
See Also: textShouldBeginEditing, textDidBeginEditing, textShouldEndEditing:, textDidEndEditing
public void textDidEndEditing(NSNotification aNotification)
See the NSControl class specification for more information on the text delegate method.
See Also: textShouldBeginEditing, textDidBeginEditing, textDidChange, textShouldEndEditing:
public boolean textShouldBeginEditing(NSText textObject)
false
immediately.
If it is editable and its delegate responds to control:textShouldBeginEditing:,
invokes that method and returns the result. Otherwise simply returns true
to
allow editing to occur. See the NSControl class specification for
more information on the text delegate method.See Also: textDidBeginEditing, textDidChange, textShouldEndEditing:, textDidEndEditing
public boolean textShouldEndEditing(NSText textObject)
false
. See
the NSControl class specification for more information on the text
delegate method.See Also: textShouldBeginEditing, textDidBeginEditing, textDidChange, textDidEndEditing, errorAction