Table of Contents

NSForm


Inherits from:
NSMatrix : NSControl : NSView : NSResponder : NSObject
Package:
com.apple.yellow.application


Class Description


An NSForm is a vertical NSMatrix of NSFormCells. Here's an example:

[image: Art/Form.gif]

In NSForm's methods, each NSFormCell is called an "entry" (or, sometimes, a "cell" or "item"). The left part of each entry is called the "title," and the right part is called the "text." Methods that refer to individual entries use an one-dimensional "index"; the indexing system starts at the top of the top of form, with zero.

Any entry in the form can be "selected." When an entry is selected, its text area responds to the user's keystrokes. You can select an entry using the selectTextAtIndex method, or you can let the user select an entry by clicking it with the mouse. Once an entry is selected, the user can select the next entry by pressing Tab, or select the previous entry by pressing Shift-Tab.

To initiate the action of a selected entry, the user presses Return or Enter. In response, the entry sends an action message to its target. If the entry has no target, the NSForm sends an action message to its target.

NSForm includes a methods to change the appearance of entries (the set... methods). These methods affect every entry in the form. To change the appearance of an individual entry, you need to single it out, using cellAtIndex, and then send it messages appropriate to an "NSFormCell" .

For more information, see the class specifications for "NSFormCell" and NSMatrix.




Method Types


Constructors
NSForm
Adding and removing entries
addEntry
insertEntryAtIndex
removeEntryAtIndex
Changing the appearance of all the entries
setBezeled
setBordered
setEntryWidth
setInterlineSpacing
setTitleAlignment
setTextAlignment
setTitleFont
setTextFont
Getting cells and indices
indexOfCellWithTag
indexOfSelectedItem
cellAtIndex
Displaying a cell
drawCellAtIndex
Editing text
selectTextAtIndex


Constructors



NSForm

public NSForm()

Description forthcoming.

public NSForm(NSRect aRect)

Description forthcoming.

public NSForm( NSRect aRect, int anInt, NSCell aCell, int anInt, int anInt)

Description forthcoming.

public NSForm( NSRect aRect, int anInt, Class aClass, int anInt, int anInt)

Description forthcoming.


Instance Methods



addEntry

public NSFormCell addEntry(String title)

Adds a new entry to the end of the form, and gives it the title title. The new entry has no tag, target, or action, but is enabled and editable.

See Also: insertEntryAtIndex, setEditable (NSCell), setTag (NSActionCell), setTarget (NSActionCell), setAction (NSActionCell), setEnabled (NSActionCell)



cellAtIndex

public NSCell cellAtIndex(int entryIndex)

Returns the entry specified by entryIndex.

See Also: indexOfCellWithTag, indexOfSelectedItem



drawCellAtIndex

public void drawCellAtIndex(int entryIndex)

Displays the entry specified by entryIndex. 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.

See Also: indexOfCellWithTag, indexOfSelectedItem



indexOfCellWithTag

public int indexOfCellWithTag(int tag)

Returns the index of the entry whose tag is tag.

See Also: tag (NSCell)



indexOfSelectedItem

public int indexOfSelectedItem()

Returns the index of the selected entry. If no entry is selected, indexOfSelectedItem returns -1.

insertEntryAtIndex

public NSFormCell insertEntryAtIndex( String title, int entryIndex)

Inserts an entry with the title title at the position in the form specified by entryIndex. The new entry has no tag, target, or action, and, as explained in the class description, it won't appear on the screen automatically.

Returns the newly inserted NSFormCell.

See Also: addEntry, removeEntryAtIndex



removeEntryAtIndex

public void removeEntryAtIndex(int entryIndex)

Removes the entry at entryIndex. If entryIndex is not a valid position in the form, does nothing.

selectTextAtIndex

public void selectTextAtIndex(int entryIndex)

Selects the entry at entryIndex. If entryIndex is not a valid position in the form, does nothing.

setBezeled

public void setBezeled(boolean flag)

If flag is true, sets all the entries in the form to show a bezel around their editable text; if flag is false, sets all the entries to show no bezel.

See Also: setBordered, isBezeled (NSCell)



setBordered

public void setBordered(boolean flag)

Sets whether the entries in the form display a border-that is, a thin line-around their editable text fields. If flag is true, they display a border; otherwise, they don't. An entry can have a border or a bezel, but not both.

See Also: setBezeled, isBordered (NSCell)



setEntryWidth

public void setEntryWidth(float width)

Sets the width (in pixels) of all the entries in the form. This width includes both the title and the text field.

setInterlineSpacing

public void setInterlineSpacing(float spacing)

Sets the number of pixels between entries in the form to spacing.

setTextAlignment

public void setTextAlignment(int alignment)

Sets the alignment for all of the form's editable text. alignment can be one of three constants: NSText.RightTextAlignment, NSText.CenterTextAlignment, or NSText.LeftTextAlignment (the default).

See Also: setTitleAlignment



setTextFont

public void setTextFont(NSFont font)

Sets the font for all of the form's editable text fields.

See Also: setTextFont



setTitleAlignment

public void setTitleAlignment(int alignment)

Sets the alignment for all of the entry titles. alignment can be one of three constants: NSText.RightTextAlignment, NSText.CenterTextAlignment, or the default, NSText.LeftTextAlignment.

See Also: setTextAlignment



setTitleFont

public void setTitleFont(NSFont font)

Sets the font for all of the entry titles.

See Also: setTextFont




Table of Contents