A newer version of Max is available. Click here to access the latest version of this document.

toggle

Switch between off and on (0 and 1)

Description

toggle sends a 0 as output when it is turned off and a 1 as output when it is turned on (when giving input, a non-zero number will turn it on, a 0 will turn it off, and a bang will alternate the state of the toggle).

Arguments

None.

Messages

bang Switches toggle on if it is off; switches it off if it is on.
int input [int]
The number is sent out the outlet. If the number is not 0, toggle displays an X, showing it is on. If it is 0, toggle is blank, showing it is off.
float input [float]
Converted to int.
(mouse) A mouse click on toggle switches the object on if it is off/off if it is on.
set set-input [int]
Switches the toggle on or off without sending anything out the outlet. The word set, followed by any non-zero number, sets toggle to on; set 0 sets it to off.

Attributes

Name Type g/s Description
bgcolor float Sets the background color for the object in RGBA format.
bordercolor float Sets the border color of the object in RGBA format.
checkedcolor float Sets the "X" color for the object in RGBA format.

Information for box attributes common to all objects

Menu Items

Name Description
Color Choosing the Color... menu item from the Object menu when the object is selected opens a color picker, permitting adjustment to the appearance of the toggle object.

Output

int: A number received in the inlet is sent out the outlet. A bang or a mouse click sends 1 or 0 out the outlet, depending on whether toggle is being turned on or off.

Examples

Used as an onscreen controller or to display the on/off status of numbers passing through

See Also

Name Description
led Display on/off status in color
matrixctrl Matrix switch control
pictctrl Picture-based control
radiogroup Radio button/check box user interface object
togedge Report zero/non-zero transitions
Max Basic Tutorial 4: Metro and Toggle Max Basic Tutorial 4: Metro and Toggle