NSForm Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in OS X v10.0 and later. |
| Declared in | NSForm.h |
| Companion guides | |
Tasks
Adding and Removing Entries
Changing the Appearance of All the Entries
-
– setBezeled: -
– setBordered: -
– setEntryWidth: -
– setFrameSize: -
– setInterlineSpacing: -
– setTitleAlignment: -
– setTitleBaseWritingDirection: -
– setTextAlignment: -
– setTextBaseWritingDirection: -
– setTitleFont: -
– setTextFont:
Getting Cells and Indices
Displaying a Cell
Autolayout Sizing
Editing Text
Instance Methods
addEntry:
Adds a new entry to the end of the receiver and gives it the specified title.
Parameters
- title
The title for the new form entry.
Return Value
The form cell object that was created for the entry.
Discussion
The new entry has no tag, target, or action, but is enabled and editable.
Availability
- Available in OS X v10.0 and later.
See Also
-
– insertEntry:atIndex: -
setEditable:(NSCell) -
setTag:(NSActionCell) -
setTarget:(NSActionCell) -
setAction:(NSActionCell) -
setEnabled:(NSCell)
Declared In
NSForm.hcellAtIndex:
Returns the entry at the specified index.
Parameters
- entryIndex
The index of the desired entry.
Return Value
The form cell object at the specified index.
Availability
- Available in OS X v10.0 and later.
Declared In
NSForm.hdrawCellAtIndex:
Displays the entry at the specified index.
Parameters
- entryIndex
The index of the entry to draw.
Discussion
Because this method is called automatically whenever a cell needs drawing, you never need to invoke it explicitly. It is included in the API so you can override it if you subclass NSFormCell.
Availability
- Available in OS X v10.0 and later.
Declared In
NSForm.hindexOfCellWithTag:
Returns the index of the entry whose tag is tag.
Parameters
- tag
The tag of the desired entry.
Availability
- Available in OS X v10.0 and later.
See Also
-
tag(NSCell)
Declared In
NSForm.hindexOfSelectedItem
Returns the index of the selected entry.
Return Value
The index of the selected entry, or -1 if no entry is selected.
Availability
- Available in OS X v10.0 and later.
Declared In
NSForm.hinsertEntry:atIndex:
Inserts an entry with the specified title into the receiver.
Parameters
- title
The title for the new form entry.
- entryIndex
The zero-based index at which to insert the entry.
Return Value
The form cell object that was created for the entry.
Discussion
The new entry has no tag, target, or action, but is enabled and editable.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSForm.hpreferredTextFieldWidth
The preferred width of the form’s cells when using auto layout.
Return Value
The field’s width.
Discussion
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.
The default is -1.
Availability
- Available in OS X v10.8 and later.
See Also
Declared In
NSForm.hremoveEntryAtIndex:
Removes and releases the entry at the specified index.
Parameters
- entryIndex
The zero-based index identifying the desired entry.
Discussion
If the specified index is invalid, this method does nothing.
Availability
- Available in OS X v10.0 and later.
Declared In
NSForm.hselectTextAtIndex:
Selects the entry at the specified index.
Parameters
- entryIndex
The index of the entry to select. If the specified index is invalid, this method does nothing.
Availability
- Available in OS X v10.0 and later.
Declared In
NSForm.hsetBezeled:
Sets whether the receiver's entries should display a bezel around their editable text.
Parameters
- flag
YESto display a bezel around all entries; otherwise,NOto show no bezel around all entries.
Availability
- Available in OS X v10.0 and later.
See Also
-
– setBordered: -
isBezeled(NSCell)
Declared In
NSForm.hsetBordered:
Sets whether the receiver's entries should display a border around their editable text fields.
Parameters
- flag
YESto display a border around all entries; otherwise,NOto show no border around all entries.
Discussion
The border is drawn as a thin line around the editable text field. An entry can have a border or a bezel, but not both.
Availability
- Available in OS X v10.0 and later.
See Also
-
– setBezeled: -
isBordered(NSCell)
Declared In
NSForm.hsetEntryWidth:
Sets the width of all the entries in the receiver.
Parameters
- width
The width of all entries, measured in points in the user coordinate space. This value represents the width of both the title and the text field.
Availability
- Available in OS X v10.0 and later.
Declared In
NSForm.hsetFrameSize:
Sets the size of the receiver’s frame size to the specified value.
Parameters
- newSize
The new size of the form.
Discussion
The width of NSFormCell objects always match the width of their encompassing NSForm object. The cell width is always changed to match the view regardless of the value returned by autosizesCells.
Availability
- Available in OS X v10.3 and later.
Declared In
NSForm.hsetInterlineSpacing:
Sets the spacing between entries
Parameters
- spacing
The spacing between entries, measured in points in the user coordinate space.
Availability
- Available in OS X v10.0 and later.
Declared In
NSForm.hsetPreferredTextFieldWidth:
Sets the preferred text field width used by auto layout.
Parameters
- preferredWidth
The preferred width.
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 form. 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.
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 preferredTextFieldWidth.
This method can aid migration to autolayout, and is sufficient for simple cases. However, for new apps, use NSTextField objects directly instead of NSForm.
The default is -1.
Availability
- Available in OS X v10.8 and later.
See Also
Declared In
NSForm.hsetTextAlignment:
Sets the alignment for all of the receiver’s editable text.
Parameters
- alignment
The alignment can be one of the following constants:
NSRightTextAlignment,NSCenterTextAlignment, orNSLeftTextAlignment.
Discussion
The default alignment is NSLeftTextAlignment.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSForm.hsetTextBaseWritingDirection:
Sets the writing direction for the text content of every control embedded in the form.
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
-
baseWritingDirection(NSControl)
Declared In
NSForm.hsetTextFont:
Sets the font for all of the receiver’s editable text fields
Parameters
- font
The font to use for all editable text fields.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSForm.hsetTitleAlignment:
Sets the alignment for all of the entry titles.
Parameters
- alignment
The alignment can be one of the following constants:
NSRightTextAlignment,NSCenterTextAlignment, orNSLeftTextAlignment.
Discussion
The default alignment is NSRightTextAlignment.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSForm.hsetTitleBaseWritingDirection:
Sets the writing direction for the title of every control embedded in the form.
Parameters
- writingDirection
This value can be one of the following constants:
NSWritingDirectionNatural,NSWritingDirectionLeftToRight, orNSWritingDirectionRightToLeft.
Availability
- Available in OS X v10.4 and later.
Declared In
NSForm.hsetTitleFont:
Sets the font for all of the entry titles.
Parameters
- font
The font to use for all entry titles.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSForm.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)