A pop-up menu which which synchronizes with a target object's string value by
getter functions are used to synchronize the menu and target object.
getter returns the string value that corresponds to the target state
setter modifies the target state to correspond to the given string value
The menu is initially set to show the the target's current value, as given by the
When a menu item is selected, the target is modified by calling the
setter with the
value corresponding to the selected choice.
ChoiceControlBase has two (same-length) arrays:
The array of choices are the strings which are displayed in the menu. These should be localized (translated) strings.
The array of values are strings that correspond to each choice. The value is given to the setter function to change the target object.
A ChoiceControlBase can be in a state of 'no selection', which is indicated by index of
–1 in setChoice or getChoice.
In this case, the menu item shown is
blank (no text is shown, just empty space). This happens when the value returned by the
getter function is not among the array of ChoiceControlBase values.
When moving into a state of 'no selection', no notification is given via the
setter function. When moving out of the 'no selection' state, the
is called as normal.
To keep the control in sync with the target object, call the observe method whenever a change in the value of the target object occurs. If the target object is a Subject then you can add this control as an Observer of the Subject.
an array of localized strings giving the names of the menu items.
array of values corresponding to the choices, in string form; these values will be supplied to the setter function when the corresponding menu item is chosen
function that returns the value that corresponds to the target's current state
function that modifies the target's state to be the given string value
Optional opt_label: null | string
the text label to show besides this choice; if
undefined or empty string then no label is made.
The menu items shown to the user for each choice, an array of localized (translated) strings.
the currently selected item, or -1 if no item selected
Remove connections to other objects to facilitate garbage collection. For example, stops listening for user interface events.
Returns the index of the currently selected choice, or -1 if no item selected. The first item has index zero. See setChoice.
the index of the currently selected choice, or -1 if no item selected
Returns name of class of this object.
name of class of this object.
Returns the top level Element of this control. For example, this might be a label Element that encloses an input Element.
the top level Element of this control
Returns the Parameter that this LabControl is connected to, if any.
the Parameter that this LabControl is connected to, or
the event that caused this callback to fire
Notifies this Observer that a change has occurred in the Subject.
contains information about what has changed in the Subject: typically either a one-time GenericEvent, or a change to the value of a Parameter
Changes the menu item shown by this control, and sets the target to have the
corresponding value by firing the
setter function. An index of -1 causes this control
to enter the
"no selection" state.
the index of the chosen item within array of choices, where the first item has index zero and -1 means no item is selected
Changes the array of choices and modifies the current choice to match the target's
setter function is not called.
the new set of choices to display
the new set of values that correspond to the choices
if choices and values have different length
Enables or disables the control.
whether to enable the control
Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.
For an object whose main purpose is to represent another Printable object, it is
recommended to include the result of calling
toStringShort on that other object.
For example, calling
toStringShort() on a DisplayShape might return something like
a minimal string representation of this object.
Generated using TypeDoc