# WRTKit SelectionMenu Class

## Description

The SelectionMenu class is an implementation of a selection control that lets users select options from a popup menu.

The SelectionMenu control has two modes: a display mode and a selection mode. Normally the display mode is shown and users can see what the currently selected options are. When a user selects the control a menu pops up that displays the available options. The user can then select the option (or options) from this menu. After the selection is done the menu goes away and the control returns to display mode. The SelectionMenu control is useful in situations where there are many options and showing them all uses up too much space.

Figure 1. SelectionMenu control

## Inherits from

SelectionControl

Parent topic: WRTKit API Reference

## Constructor

### Syntax

    [SelectionMenu] new SelectionMenu(String id, String caption, Array options, Boolean multipleSelection, Array|Option selected)

### Description

Creates a new instance of the SelectionMenu class.

### Arguments

- id

  Unique identifier for the control. Can be retrieved using the id property defined in the UIElement class that this control inherits from. Useful for example to identify the source of an event in event callback functions or to apply a CSS rule to only this particular control. The identifier can be null, in which case no id will be set for the control.

- caption

  The caption text for the control. A null caption can be used to hide the caption area. The value is an XHTML string.

- options

  An array of options that the selection menu should display to the user. If the argument is omitted or null the control will not display any options. The options can be set or changed later by calling setOptions(). Options are objects with two properties: value and text. Use JavaScript object notation (JSON) to construct option objects, e.g. `{ value: "value here", text: "Text for value goes here" }`. The text value is an XHTML string.

- multipleSelection

  The multipleSelection argument is a boolean flag that determines whether the control should be in multipleSelection mode or not. Use true to put the control in multiple selection mode and false to put it in single selection mode. If this argument is omitted the control will go to single selection mode by default.

- selected

  The selected argument specifies which of the options should be selected at creation time. For multiple selection controls this should be given as an array of option objects with an empty array if no options should be selected. For single selection controls this should be the single option object that should be selected or null if no option should be selected. If the argument is omitted or null no options will be selected.

### Return value

A new instance of the SelectionMenu class.