A pop-up menu which synchronizes its state with the Parameter of a Subject.

When the value of the ChoiceControl is changed, the Parameter's value is changed accordingly and therefore the Subject broadcasts the Parameter's value to all its Observers.

ChoiceControl extends ChoiceControlBase, which has getter and setter functions that operate on strings. Therefore the getter and setter functions used here are Parameter.getAsString and Parameter.setFromString.

Choices and Values

If the choices and values are not specified as arguments to the constructor, then the choices and values of the Parameter are used, see Parameter.getChoices and Parameter.getValues.

If the choices and values are specified as arguments to the constructor, those will override the choices and values of the Parameter.

Hierarchy (view full)

Constructors

  • Parameters

    • parameter: Parameter

      the Parameter to modify

    • Optional opt_label: null | string

      the text label to show besides this choice, or null or empty string for no label. If undefined, then the Parameter's name is used.

    • Optional opt_choices: string[]

      an array of localized strings giving the names of the menu items; if not specified, then the Parameter's choices are used.

    • Optional opt_values: string[]

      array of values corresponding to the choices; if not specified, then the Parameter's values are used.

    Returns ChoiceControl

Properties

choices: string[]

The menu items shown to the user for each choice, an array of localized (translated) strings.

Methods

  • Notifies this Observer that a change has occurred in the Subject.

    Parameters

    • event: SubjectEvent

      contains information about what has changed in the Subject: typically either a one-time GenericEvent, or a change to the value of a Parameter

    Returns void

  • 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.

    Parameters

    • index: number

      the index of the chosen item within array of choices, where the first item has index zero and -1 means no item is selected

    Returns void

  • Changes the array of choices and modifies the current choice to match the target's state. The setter function is not called.

    Parameters

    • choices: string[]

      the new set of choices to display

    • values: string[]

      the new set of values that correspond to the choices

    Returns void

    Throws

    if choices and values have different length

  • 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 this:

    DisplayShape{polygon:Polygon{'chain3'}}
    

    Returns string

    a minimal string representation of this object.

Generated using TypeDoc