Skip to content

EmuRadioArray

Michael edited this page Jul 3, 2021 · 3 revisions

A radio array is a collection of options, of which only one may be selected at any given time. They are useful for settings which much exist in one of a finite number of discrete states.

A horizontal radio array.

Constructor

Inheritance: EmuCore / EmuCallback

EmuRadioArray(name)
Parameter Type Description
x real The x coordinate where the radio array will be created
y real The y coordinate where the radio array will be created
w real The width of the radio array
h real The height of the radio array
value real The initial value of the radio array
callback function The callback that will be invoked when the value of the radio array is changed

Relevant Methods

EmuRadioArray::AddOptions(elements)

Returns: self

Parameter Type Description
elements string The elements you wish to add to the radio array

Use this to add options to a radio array. If you provide a single string, it will be added by itself whereas an array of strings will add each element in the array.

EmuRadioArray::SetColumns(column_capacity, column_width)

Returns: self

Parameter Type Description
column_capacity real The maximum number of elements in each column (0 to set all elements into one column)
column_width real The width of each column

Use this to arrange the radio array options into multiple columns. This can be useful if you have many options which don't fit neatly onto the screen when in a single column. A value of 0 or less for column_capacity (or an arbitrarily large value) will reset all elements into one column.

Calling this at a point after the element has been created may cause formatting issues.

Example

var radio = new EmuRadioArray(32, u, 256, 32, "Select your favorite planet:", 0, function() {
    show_message("You have chosen planet #" + string(value) + ".");
});
radio.AddOptions(["Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"]);
radio.SetColumns(3, 160);

container.AddContent(radio);

This will create an EmuRadioArray of the eight planets currently in our Solar System, and arrange them into columns of up to three elements each. The radio element will then be added to a previously-defined container.

Clone this wiki locally