Next Page > Hide TOC

NSForm Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in Mac OS X v10.0 and later.
Declared in
NSForm.h
Companion guides

Overview

An NSForm object is a vertical matrix of NSFormCell objects. Here’s an example:


image: Art/form.gif

An NSForm object uses NSFormCell to implement its user interface.

Tasks

Adding and Removing Entries

Changing the Appearance of All the Entries

Getting Cells and Indices

Displaying a Cell

Editing Text

Instance Methods

addEntry:

Adds a new entry to the end of the receiver and gives it the specified title.

- (NSFormCell *)addEntry:(NSString *)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
See Also
Declared In
NSForm.h

cellAtIndex:

Returns the entry at the specified index.

- (id)cellAtIndex:(NSInteger)entryIndex

Parameters
entryIndex

The index of the desired entry.

Return Value

The form cell object at the specified index.

Availability
See Also
Declared In
NSForm.h

drawCellAtIndex:

Displays the entry at the specified index.

- (void)drawCellAtIndex:(NSInteger)entryIndex

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
See Also
Declared In
NSForm.h

indexOfCellWithTag:

Returns the index of the entry whose tag is tag.

- (NSInteger)indexOfCellWithTag:(NSInteger)tag

Parameters
tag

The tag of the desired entry.

Availability
See Also
Declared In
NSForm.h

indexOfSelectedItem

Returns the index of the selected entry.

- (NSInteger)indexOfSelectedItem

Return Value

The index of the selected entry, or -1 if no entry is selected.

Availability
Declared In
NSForm.h

insertEntry:atIndex:

Inserts an entry with the specified title into the receiver.

- (NSFormCell *)insertEntry:(NSString *)title atIndex:(NSInteger)entryIndex

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
See Also
Declared In
NSForm.h

removeEntryAtIndex:

Removes and releases the entry at the specified index.

- (void)removeEntryAtIndex:(NSInteger)entryIndex

Parameters
entryIndex

The zero-based index identifying the desired entry.

Discussion

If the specified index is invalid, this method does nothing.

Availability
Declared In
NSForm.h

selectTextAtIndex:

Selects the entry at the specified index.

- (void)selectTextAtIndex:(NSInteger)entryIndex

Parameters
entryIndex

The index of the entry to select. If the specified index is invalid, this method does nothing.

Availability
Declared In
NSForm.h

setBezeled:

Sets whether the receiver's entries should display a bezel around their editable text.

- (void)setBezeled:(BOOL)flag

Parameters
flag

YES to display a bezel around all entries; otherwise, NO to show no bezel around all entries.

Availability
See Also
Declared In
NSForm.h

setBordered:

Sets whether the receiver's entries should display a border around their editable text fields.

- (void)setBordered:(BOOL)flag

Parameters
flag

YES to display a border around all entries; otherwise, NO to 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
See Also
Declared In
NSForm.h

setEntryWidth:

Sets the width of all the entries in the receiver.

- (void)setEntryWidth:(CGFloat)width

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
Declared In
NSForm.h

setFrameSize:

Sets the size of the receiver’s frame size to the specified value.

- (void)setFrameSize:(NSSize)newSize

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
Declared In
NSForm.h

setInterlineSpacing:

Sets the spacing between entries

- (void)setInterlineSpacing:(CGFloat)spacing

Parameters
spacing

The spacing between entries, measured in points in the user coordinate space.

Availability
Declared In
NSForm.h

setTextAlignment:

Sets the alignment for all of the receiver’s editable text.

- (void)setTextAlignment:(NSInteger)alignment

Parameters
alignment

The alignment can be one of the following constants: NSRightTextAlignment, NSCenterTextAlignment, or NSLeftTextAlignment.

Discussion

The default alignment is NSLeftTextAlignment.

Availability
See Also
Declared In
NSForm.h

setTextBaseWritingDirection:

Sets the writing direction for the text content of every control embedded in the form.

- (void)setTextBaseWritingDirection:(NSWritingDirection)writingDirection

Parameters
writingDirection

This value can be one of the following constants: NSWritingDirectionNatural, NSWritingDirectionLeftToRight, or NSWritingDirectionRightToLeft.

Availability
See Also
Declared In
NSForm.h

setTextFont:

Sets the font for all of the receiver’s editable text fields

- (void)setTextFont:(NSFont *)font

Parameters
font

The font to use for all editable text fields.

Availability
See Also
Declared In
NSForm.h

setTitleAlignment:

Sets the alignment for all of the entry titles.

- (void)setTitleAlignment:(NSTextAlignment)alignment

Parameters
alignment

The alignment can be one of the following constants: NSRightTextAlignment, NSCenterTextAlignment, or NSLeftTextAlignment.

Discussion

The default alignment is NSRightTextAlignment.

Availability
See Also
Declared In
NSForm.h

setTitleBaseWritingDirection:

Sets the writing direction for the title of every control embedded in the form.

- (void)setTitleBaseWritingDirection:(NSWritingDirection)writingDirection

Parameters
writingDirection

This value can be one of the following constants: NSWritingDirectionNatural, NSWritingDirectionLeftToRight, or NSWritingDirectionRightToLeft.

Availability
Declared In
NSForm.h

setTitleFont:

Sets the font for all of the entry titles.

- (void)setTitleFont:(NSFont *)font

Parameters
font

The font to use for all entry titles.

Availability
See Also
Declared In
NSForm.h

Next Page > Hide TOC


© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.