NSFormCell Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Companion guide | |
| Declared in | NSFormCell.h |
Overview
The NSFormCell class is used to implement text entry fields in a form. The left part of an NSFormCell object contains a title. The right part contains an editable text entry field.
An NSFormCell object implements the user interface of an NSForm object.
Tasks
Initializing an NSFormCell
Asking About a Cell’s Appearance
Asking About a Cell’s Title
-
– attributedTitle -
– title -
– titleAlignment -
– titleBaseWritingDirection -
– titleFont -
– titleWidth -
– titleWidth:
Changing the Cell’s Title
-
– setAttributedTitle: -
– setTitle: -
– setTitleAlignment: -
– setTitleBaseWritingDirection: -
– setTitleFont: -
– setTitleWidth:
Setting a Keyboard Equivalent
-
– setTitleWithMnemonic:Deprecated in OS X v10.8
Asking About Placeholder Values
-
– placeholderAttributedString -
– placeholderString -
– setPlaceholderAttributedString: -
– setPlaceholderString:
Sizing for Autolayout
Instance Methods
attributedTitle
Returns the title of the cell as an attributed string.
Return Value
The title of the cell.
Availability
- Available in OS X v10.0 and later.
Declared In
NSFormCell.hinitTextCell:
Returns an NSFormCell object initialized with the specified title string.
Parameters
- aString
The title for the new form cell object.
Return Value
An initialized NSFormCell object.
Discussion
The contents of the cell's editable text entry field are set to the empty string (@“”). The font for both title and text is the user’s chosen system font in 12.0 point, and the text area is drawn with a bezel. This method is the designated initializer for the NSFormCell class.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSFormCell.hisOpaque
Returns a Boolean value indicating whether the title is empty and an opaque bezel is set.
Return Value
YES if the title is empty and an opaque bezel is set; otherwise, NO.
Availability
- Available in OS X v10.0 and later.
Declared In
NSFormCell.hplaceholderAttributedString
Returns the cell’s attributed placeholder string.
Return Value
The attributed placeholder string, or nil if the cell has no attributed placeholder string.
Discussion
If this method returns nil, you can also call placeholderString to see if the cell has a plain text placeholder string.
Availability
- Available in OS X v10.4 and later.
Declared In
NSFormCell.hplaceholderString
Returns the cell’s plain text placeholder string.
Return Value
The plain-text placeholder string, or nil if the cell has no plain-text placeholder string.
Discussion
If this method returns nil, you can also call placeholderAttributedString to see if the cell has an attributed placeholder string.
Availability
- Available in OS X v10.4 and later.
Declared In
NSFormCell.hpreferredTextFieldWidth
Returns the preferred text field width.
Return Value
Returns the preferred width which will be large enough to accommodate the title, bezel, and a text field of width preferredTextFieldWidth.
Availability
- Available in OS X v10.8 and later.
See Also
Declared In
NSFormCell.hsetAttributedTitle:
Sets the receiver’s title using an attributed string.
Parameters
- anAttributedString
The formatted title of the cell.
Availability
- Available in OS X v10.0 and later.
Declared In
NSFormCell.hsetPlaceholderAttributedString:
Sets the attributed placeholder string for the cell.
Parameters
- string
The attributed placeholder string.
Discussion
Note that invoking this method clears out any plain text string set by calling the setPlaceholderString: method.
Availability
- Available in OS X v10.4 and later.
Declared In
NSFormCell.hsetPlaceholderString:
Sets the plain-text placeholder string for the cell.
Parameters
- string
The plain-text placeholder string.
Discussion
Note that invoking this method clears out any attributed string set by the setPlaceholderAttributedString: method.
Availability
- Available in OS X v10.4 and later.
Declared In
NSFormCell.hsetPreferredTextFieldWidth:
Sets the preferred text field width.
Parameters
- preferredWidth
The the preferred width which will be large enough to accommodate the
title,bezel, and a text field of widthpreferredTextFieldWidth.
Discussion
The preferred width is reflected in the cell's cellSize, which will be large enough to accommodate the title, bezel, and a text field of width preferredTextWidth. It is also reflected in the intrinsicContentSize of the NSForm. That is, under autolayout, the form will try to size itself so that the text field cell is the given width, according to the usual content size constraint priorities.
If the width is negative, the cellSize matches the historic behavior, which is that it is large enough to accommodate the title, bezel, and the current text.
This method can aid migration to autolayout, and is sufficient for simple cases. However, for new apps, prefer to use NSTextField instance directly instead of forms.
The default is -1.
Availability
- Available in OS X v10.8 and later.
See Also
Declared In
NSFormCell.hsetTitle:
Sets the receiver’s title to the specified plain-text string.
Parameters
- aString
The plain-text title of the cell.
Availability
- Available in OS X v10.0 and later.
Declared In
NSFormCell.hsetTitleAlignment:
Sets the alignment of the title.
Parameters
- alignment
The alignment can be one of the following constants:
NSRightTextAlignment,NSCenterTextAlignment, orNSLeftTextAlignment.
Availability
- Available in OS X v10.0 and later.
Declared In
NSFormCell.hsetTitleBaseWritingDirection:
Sets the default writing direction used to render the form cell’s title.
Parameters
- writingDirection
This value can be one of the following constants:
NSWritingDirectionNatural,NSWritingDirectionLeftToRight, orNSWritingDirectionRightToLeft.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSFormCell.hsetTitleFont:
Sets the font of the receiver's title.
Parameters
- font
The font to use.
Availability
- Available in OS X v10.0 and later.
Declared In
NSFormCell.hsetTitleWidth:
Sets the width of the title.
Parameters
- width
The width of the title, measured in points in the user coordinate space.
Discussion
You usually do not need to invoke this method. The Application Kit automatically sets the title width whenever the title changes. If the automatic width doesn’t suit your needs, though, you can use this method to set the width explicitly.
Once you have set the width this way, the Application Kit stops setting the width automatically; you must invoke this method every time the title changes. If you want the Application Kit to resume automatic width assignments, invoke this method with a negative width value.
Availability
- Available in OS X v10.0 and later.
Declared In
NSFormCell.htitle
Returns the receiver’s title.
Return Value
The title of the cell. The default value is "Field:".
Availability
- Available in OS X v10.0 and later.
Declared In
NSFormCell.htitleAlignment
Returns the alignment of the title.
Return Value
The alignment can be one of the following values: NSLeftTextAlignment, NSCenterTextAlignment, or NSRightTextAlignment. The default alignment is NSRightTextAlignment.
Availability
- Available in OS X v10.0 and later.
Declared In
NSFormCell.htitleBaseWritingDirection
Returns the default writing direction used to render the form cell’s title.
Return Value
One of the following constants: NSWritingDirectionNatural, NSWritingDirectionLeftToRight, or NSWritingDirectionRightToLeft.
Availability
- Available in OS X v10.4 and later.
See Also
Declared In
NSFormCell.htitleFont
Returns the font used to draw the receiver’s title.
Return Value
The font object used for the title.
Availability
- Available in OS X v10.0 and later.
Declared In
NSFormCell.htitleWidth
Returns the width of the title field.
Return Value
The width of the title field, measured in points in the user coordinate space.
Discussion
If you set the width using setTitleWidth:, this method returns the value you set; otherwise, it returns the width calculated automatically by the Application Kit.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSFormCell.htitleWidth:
Returns the width of the title field constrained to the specified size.
Parameters
- aSize
The maximum size of the field when calculated by the Application Kit.
Return Value
The width of the title field, measured in points in the user coordinate space.
Discussion
If you set the width using setTitleWidth:, this method returns the value you set; otherwise, the Application Kit calculates the width, constraining the field size to the specified value.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSFormCell.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)