# CyclingButtonWidgetHelper.CyclicButtonBuilder

`com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder`

**Since:** 1.8.4

Builder for a cycling button, bound to the screen that created it. Supply a
 value-to-text converter, then configure its values and optional initial value.

## Type Parameters

- `T`: the type of values configured for the button

Nested type declared in [CyclingButtonWidgetHelper](CyclingButtonWidgetHelper.md).

## Constructors

### new CyclingButtonWidgetHelper.CyclicButtonBuilder {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_constructor-IScreen-MethodWrapper-}

```js
new CyclingButtonWidgetHelper.CyclicButtonBuilder(IScreen screen, MethodWrapper<T, ?, TextHelper, ?> valueToText)
```

Retains the screen and value-to-text converter for subsequent widget creation.

**Parameters:**
- `screen`: the screen associated with this builder
- `valueToText`: the function converting values to non-null display text

## Methods

### action {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_action-MethodWrapper-}

```js
action(MethodWrapper<CyclingButtonWidgetHelper<T>, IScreen, Object, ?> action): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>
```

**Parameters:**
- `action`: the action to run when the button cycles

**Returns:** self for chaining.

**Since:** 1.8.4

### alternateToggle {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_alternateToggle-MethodWrapper-}

```js
alternateToggle(MethodWrapper<?, ?, Boolean, ?> alternateToggle): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>
```

Sets the function that selects the value list for each cycle: `true`
 selects the alternate list and `false` the default list. Passing
 `null` leaves the existing toggle unchanged.

**Parameters:**
- `alternateToggle`: the toggle function to determine if the button should cycle
                        through the default or the alternate values

**Returns:** self for chaining.

**Since:** 1.8.4

### alternatives {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_alternatives-T[]-}

```js
alternatives(T... values): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>
```

Replaces the alternate values; the default values are unchanged. An empty alternate list causes the builder to use only the default list, regardless of the toggle.

**Parameters:**
- `values`: the alternate values of the button

**Returns:** self for chaining.

**Since:** 1.8.4

### createWidget {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_createWidget-}

```js
createWidget(): CyclingButtonWidgetHelper<T>
```

Creates and wraps a cycling button from the builder's current configuration; this does not add it to the screen or apply the common post-creation styles. Use `build()` to create, configure, and add it.

**Returns:** the newly wrapped cycling button

### getAction {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_getAction-}

```js
getAction(): MethodWrapper<CyclingButtonWidgetHelper<T>, IScreen, Object, ?>
```

**Returns:** the configured action, or `null` if none is set

**Since:** 1.8.4

### getAlternateToggle {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_getAlternateToggle-}

```js
getAlternateToggle(): MethodWrapper<?, ?, Boolean, ?>
```

Returns the toggle that selects the list during cycling, or `null` if none is configured.

**Returns:** the configured toggle, or `null` if unset.

**Since:** 1.8.4

### getAlternateValues {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_getAlternateValues-}

```js
getAlternateValues(): List<T>
```

Returns the alternate values, initially an empty list. They are selected only when an alternate toggle is configured and this list is non-empty.

**Returns:** the list of all alternate values.

**Since:** 1.8.4

### getDefaultValues {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_getDefaultValues-}

```js
getDefaultValues(): List<T>
```

Returns the default values, initially an empty list. These are used unless a configured toggle selects a non-empty alternate list.

**Returns:** the list of all default values.

**Since:** 1.8.4

### getInitialValue {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_getInitialValue-}

```js
getInitialValue(): T
```

**Returns:** the configured initial value, or `null` if none was set

**Since:** 1.8.4

### getOption {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_getOption-}

```js
getOption(): TextHelper
```

**Returns:** the option prefix, or empty text if no option was set

**Since:** 1.8.4

### getValueToText {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_getValueToText-}

```js
getValueToText(): MethodWrapper<T, ?, TextHelper, ?>
```

**Returns:** the function used to convert values to button text

**Since:** 1.8.4

### initially {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_initially-T-}

```js
initially(T value): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>
```

Sets the value used to initialize the button. The value is not checked against
 the configured lists.

**Parameters:**
- `value`: the initial value for the cycling button

**Returns:** self for chaining.

**Since:** 1.8.4

### isOptionTextOmitted {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_isOptionTextOmitted-}

```js
isOptionTextOmitted(): boolean
```

Returns whether the builder is configured to omit the option prefix; initially
 `false`. A blank prefix is omitted regardless of this setting.

**Returns:** `true` if the prefix option text should be omitted, `false`
 otherwise.

**Since:** 1.8.4

### omitTextOption {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_omitTextOption-boolean-}

```js
omitTextOption(boolean optionTextOmitted): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>
```

Sets whether to display only the value instead of the option prefix and value.  
 A blank prefix is omitted regardless of this setting.

**Parameters:**
- `optionTextOmitted`: whether the prefix option text should be omitted or not

**Returns:** self for chaining.

**Since:** 1.8.4

### option {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_option-String-}

```js
option(String option): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>
```

Sets the prefix displayed before the value, separated by a colon. Passing
 `null` leaves the existing prefix unchanged.

**Parameters:**
- `option`: the option text of the button

**Returns:** self for chaining.

**Since:** 1.8.4

### option {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_option-TextHelper-}

```js
option(TextHelper option): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>
```

Sets the prefix from a text helper, preserving its styling. Passing
 `null` leaves the existing prefix unchanged.

**Parameters:**
- `option`: the option text of the button

**Returns:** self for chaining.

**Since:** 1.8.4

### values {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_values-T[]-}

```js
values(T... values): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>
```

Replaces the default values; the alternate values are unchanged.

**Parameters:**
- `values`: the default values of the button

**Returns:** self for chaining.

**Since:** 1.8.4

### values {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_values-T[]-T[]-}

```js
values(T[] defaults, T[] alternatives): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>
```

Sets the default and alternate values, replacing both lists while leaving the toggle unchanged.

**Parameters:**
- `defaults`: the default values of the button
- `alternatives`: the alternate values of the button

**Returns:** self for chaining.

**Since:** 1.8.4

### values {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_values-List-List-}

```js
values(List<T> defaults, List<T> alternatives): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>
```

Replaces both value lists and stores the supplied lists by reference, so later changes to either list are reflected by the builder.

**Parameters:**
- `defaults`: the default values of the button
- `alternatives`: the alternate values of the button

**Returns:** self for chaining.

**Since:** 1.8.4

### valueToText {#com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder_valueToText-MethodWrapper-}

```js
valueToText(MethodWrapper<T, ?, TextHelper, ?> valueToText): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>
```

**Parameters:**
- `valueToText`: the non-null function used to render each value as button text

**Returns:** self for chaining.

**Since:** 1.8.4
