All About Binding
Within a layout description,
bind arguments are used to specify cells within the sheet to bind the widget to. The value of a bind argument must be of type
name. A common misconception with the
@cell notation is that
@ is some kind of reference operator - it is not. The
@ operator is a quote operator which quotes a keyword or identifier and generate a
The sheet within ASL acts as a model in a Model-View-Controller pattern. A typical widget, such as a checkbox, acts as a View-Controller.
In this configuration the widget is displaying the current value in the cell to which it is bound, and when clicked on, requests a change of the model to a new value. A control will be disabled if changing the value of the cell to which it is bound will have no effect on the output of the sheet.
Not all widgets comprise both a controller and view. A widget which simply displays a value is only a view, a piece of static text may be neither.
The usual configuration for a button is a bit different. A button binds to a cell as a view, even though it doesn't display the value. The value it binds to are typically the arguments to an action. Clicking on the button will invoke the action with the value from the cell to which the button is bound. A button will be disabled if the value in the cell to which it is bound is invalid. A cells value is invalid when it is derived from information contributing to an invariant in the sheet.
A button may also act as a controller. This is the equivalent of a button with an action that simply sets a cell within the sheet. The cell to set is specified with the
bind_output argument. For example, let's say that you wanted a button which added 11 to the
value cell. That could be expressed as:
// -- in the sheet interface: value: 1; output: next_value <== value + 11; // -- in the layout button(name: "Next Value", bind: @next_value, bind_output: value);
The value of a button can also be specified with the
value argument, rather than binding. For example, a button which reset the above value to 1 would look like:
button(name: "Reset", value: 1, bind_output: @value);
Such a button acts strictly as a controller.