The one extra Button attribute is mode.
Additional JSON Attributes
- mode: There are 5 different possible modes for buttons. The default value is toggle.
- toggle: Alternates between the buttons min and max values on each press
- momentary: Outputs max when button is pressed, min when button is released or when touch travels outside button boundaries
- latch: Outputs max when button is pressed, min when button is released. As opposed to momentary, this does not release when the touch travels outside the button boundaries, only when the touch that initially triggered the button ends
- contact: The button only outputs the max value, and only when it is first pressed.
- visualToggle: The button always outputs max but toggles on and off visually (useful in some MIDI circumstances)
- label: This value is used to display text in the center of the button
- labelSize: The size of any label text displayed in the button, measured in pixels.
Scripting
Properties
- xOffset, yOffset – values that gives the location of the last touch triggering an event for the owner button. The values are measured from 0 – 1, left to right, top to bottom. Thus, if the xOffset is .5 and the yOffset is .5 the touch triggering the last event was in the center of the button.
Simple JSON
{ "name" : "myButton", "type" : "Button", "x" : 0, "y" : 0, "width" : .25, "height" : .25, }
This creates a button with a default OSC address of “/myButton”, a default mode of “toggle”, a default minimum value of 0 and a default maximum value of 1. For MIDI it will output control change 0 on channel 1 with values ranging from 0 – 127.
Extra JSON
{ "name":"myButton", "type":"Button", "x" : 0, "y" : 0, "width" : .25, "height" : .25, "mode" : "momentary", "min":-1, "max":1, "midiMin":0, "midiMax":64, "address" : "/negPos", "midiType" : "noteon", "channel":10, "midiNumber" : 1, "ontouchstart" : "buttonLabel.setValue(this.value);", "ontouchend" : "buttonLabel.setValue(this.value);", }
This button has custom min / max / mode / OSC and MIDI values. It also has two event handlers that change the value of a hypothetical additional label with the name “buttonLabel” to reflect the current value of the button.