Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

Button Element Interface

janesconference edited this page Dec 8, 2011 · 2 revisions

The Button Element is a multi-state button with a single integer value that ranges from 0 to n, where n is the number of the button states. A Button can be controlled by the user clicking on it. A series of ordered images (frames) is used to display the various Button states. When it is clicked, the Button's state advances by one and the image at the corresponding index is displayed. When the Button's state reaches the maximum state, it wraps back to state #0.

The Button interface is defined in Button.js.

Constructor

Button.prototype.getready = function (args) // {Object}

Constructor arguments (args).

Other than the Graphical Element Interface constructor parameters, Button has some unique parameters:

  • imagesArray {Array}: An array of images, ordered from the frame associated with the lowest value (0) to the frame associated with the highest.

Properties and slot

  • values.buttonvalue {Int}: The buttonvalue of a Button reflects its internal state.
  • defaultSlot {String = 'buttonvalue'}: The default slot of a knob is its only slot, called 'buttonvalue'.

Methods

setStatesNumber(), getStatesNumber()

Button.prototype.setStatesNumber = function (number) // {Int}
Button.prototype.getStatesNumber = function ()

These methods set and get dinamically the number of the Button's states. When a Button is constructed, the number of its states is the number of images in the array, or imagesArray.length. The Button's maximum number of states can be re-set at any time by setStatesNumber() (this won't automatically change the buttonvalue if it is out of the range, so a prior check is required).