# Form

## visual Form

Form stimulus.

## Constructor

#### new Form(options)

Source:
  - visual/Form.js, line 27
Mixes In:
  - module:util.ColorMixin

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | Object | ###### Properties
Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`name` | String |  |  | the name used when logging messages from this stimulus
`win` | module:core.Window |  |  | the associated Window
`pos` | Array.<number> | <optional> | `[0, 0]` | the position of the center of the slider
`size` | Array.<number> |  |  | the size of the slider, e.g. [1, 0.1] for an horizontal slider
`units` | string | <optional> | `'height'` | the units of the Slider position, and font size
`color` | Color | <optional> | `Color('LightGray')` | the color of the slider
`contrast` | number | <optional> | `1.0` | the contrast of the slider
`opacity` | number | <optional> | `1.0` | the opacity of the slider
`depth` | number | <optional> | `0` | the depth (i.e. the z order), note that the text, radio buttons and slider elements are at depth - 1
`items` | Array.<number> | <optional> | `[]` | the array of labels
`itemPadding` | number | <optional> | `0.05` | the granularity
`font` | string | <optional> | `'Arial'` | the text font
`fontFamily` | string | <optional> | `'Helvetica'` | the text font
`bold` | boolean | <optional> | `true` | whether or not the font of the labels is bold
`italic` | boolean | <optional> | `false` | whether or not the font of the labels is italic
`fontSize` | number | <optional> |  | the font size of the labels (in form units), the default fontSize depends on the Form units: 14 for 'pix', 0.03 otherwise
`clipMask` | PIXI.Graphics | <optional> | `null` | the clip mask
`autoDraw` | boolean | <optional> | `false` | whether or not the stimulus should be automatically drawn on every frame flip
`autoLog` | boolean | <optional> | `false` | whether or not to log

### Extends

- module:visual.VisualStim

### Members

#### (protected, static, readonly) _defaultItems

Source:
  - visual/Form.js, line 1146

Default form item.

#### (static, readonly) Layout :Symbol

Source:
  - visual/Form.js, line 1134

##### Properties:

Name | Type | Description
--- | --- | ---
`HORIZONTAL` | Symbol |
`VERTICAL` | Symbol |

Form item layout.

##### Type:

- Symbol

#### (static, readonly) Types :Symbol

Source:
  - visual/Form.js, line 1118

##### Properties:

Name | Type | Description
--- | --- | ---
`HEADING` | Symbol |
`DESCRIPTION` | Symbol |
`RATING` | Symbol |
`SLIDER` | Symbol |
`FREE_TEXT` | Symbol |
`CHOICE` | Symbol |
`RADIO` | Symbol |

Form item types.

##### Type:

- Symbol

### Methods

#### (protected) _estimateBoundingBox()

Source:
  - visual/Form.js, line 658
Overrides:
  - module:visual.VisualStim#_estimateBoundingBox

Estimate the bounding box.

#### (protected) _getBoundingBox_px() → {PIXI.Rectangle}

Source:
  - visual/VisualStim.js, line 234
Overrides:
  - module:visual.VisualStim#_getBoundingBox_px

Get the bounding box in pixel coordinates

##### Returns:

the bounding box, in pixel coordinates

Type
  PIXI.Rectangle

#### (protected) _importItems()

Source:
  - visual/Form.js, line 480

Import the form items from either a spreadsheet resource files (.csv, .xlsx, etc.) or from an array.

#### (protected) _onChange(withPixiopt, withBoundingBoxopt) → {function}

Source:
  - visual/VisualStim.js, line 277
Overrides:
  - module:visual.VisualStim#_onChange

Generate a callback that prepares updates to the stimulus. This is typically called in the constructor of a stimulus, when attributes are added with _addAttribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`withPixi` | boolean | <optional> | `false` | whether or not the PIXI representation must also be updated
`withBoundingBox` | boolean | <optional> | `false` | whether or not to immediately estimate the bounding box

##### Returns:

Type
  function

#### (protected) _processItems()

Source:
  - visual/Form.js, line 441

Import and process the form items from either a spreadsheet resource files (.csv, .xlsx, etc.) or from an array.

#### (protected) _sanitizeItems()

Source:
  - visual/Form.js, line 525

Sanitize the form items: check that the keys are valid, and fill in default values.

#### (protected) _setupStimuli()

Source:
  - visual/Form.js, line 674

Setup the stimuli, and the scrollbar.

#### (protected) _updateDecorations()

Source:
  - visual/Form.js, line 1050

Update the form decorations (bounding box, lines between items, etc.)

#### (protected) _updateIfNeeded()

Source:
  - visual/Form.js, line 942
Overrides:
  - module:visual.VisualStim#_updateIfNeeded

Update the form visual representation, if necessary.

This estimate which stimuli are visible, and updates the decorations.

#### (protected) _updateVisibleStimuli()

Source:
  - visual/Form.js, line 999

Update the visible stimuli.

#### addDataToExp(experiment, formatopt)

Source:
  - visual/Form.js, line 394

Add the form data to the given experiment.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`experiment` | module:data.ExperimentHandler |  |  | the experiment into which to insert the form data
`format` | string | <optional> | `'rows'` | whether to insert the data as rows or as columns

#### contains(object, units) → {boolean}

Source:
  - visual/VisualStim.js, line 196
Overrides:
  - module:visual.VisualStim#contains

Determine whether an object is inside the bounding box of the stimulus.

##### Parameters:

Name | Type | Description
--- | --- | ---
`object` | Object | the object
`units` | string | the units

##### Returns:

whether or not the object is inside the bounding box of the stimulus

Type
  boolean

#### draw()

Source:
  - visual/Form.js, line 246
Overrides:
  - module:visual.VisualStim#draw

Overridden draw that also calls the draw method of all form elements.

#### formComplete() → {boolean}

Source:
  - visual/Form.js, line 382

Check if the form is complete.

##### Returns:

- whether there are any remaining incomplete responses.

Type
  boolean

#### getData() → {object}

Source:
  - visual/Form.js, line 339

Collate the questions and responses into a single dataset.

##### Returns:

- the dataset with all questions and responses.

Type
  object

#### hide()

Source:
  - visual/Form.js, line 283
Overrides:
  - module:visual.VisualStim#hide

Overridden hide that also calls the hide method of all form elements.

#### refresh()

Source:
  - visual/Form.js, line 224
Overrides:
  - module:visual.VisualStim#refresh

Force a refresh of the stimulus.

#### release(logopt)

Source:
  - core/MinimalStim.js, line 161
Overrides:
  - module:visual.VisualStim#release

Release the PIXI representation, if there is one.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`log` | boolean | <optional> | `false` | whether to log

#### reset()

Source:
  - visual/Form.js, line 314

Reset the form.

#### setAutoDraw(autoDraw, logopt)

Source:
  - core/MinimalStim.js, line 62
Overrides:
  - module:visual.VisualStim#setAutoDraw

Setter for the autoDraw attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`autoDraw` | boolean |  |  | the new value
`log` | boolean | <optional> | `false` | whether to log

#### setDepth(depth, logopt)

Source:
  - visual/VisualStim.js, line 182
Overrides:
  - module:visual.VisualStim#setDepth

Setter for the depth attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`depth` | Array.<number> |  | `0` | order in which stimuli is rendered, kind of css's z-index with a negative sign.
`log` | boolean | <optional> | `false` | whether of not to log

#### setOri(ori, logopt)

Source:
  - visual/VisualStim.js, line 135
Overrides:
  - module:visual.VisualStim#setOri

Setter for the orientation attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`ori` | number |  |  | the orientation in degree with 0 as the vertical position, positive values rotate clockwise.
`log` | boolean | <optional> | `false` | whether of not to log

#### setPos(pos, logopt)

Source:
  - visual/VisualStim.js, line 161
Overrides:
  - module:visual.VisualStim#setPos

Setter for the position attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`pos` | Array.<number> |  |  | position of the center of the stimulus, in stimulus units
`log` | boolean | <optional> | `false` | whether of not to log

#### setSize(size, logopt)

Source:
  - visual/VisualStim.js, line 109
Overrides:
  - module:visual.VisualStim#setSize

Setter for the size attribute.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`size` | undefined | null | number | Array.<number> |  |  | the stimulus size
`log` | boolean | <optional> | `false` | whether of not to log