Skip to content

CyclingButtonWidgetHelper.CyclicButtonBuilder ​

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

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

Constructors ​

new CyclingButtonWidgetHelper.CyclicButtonBuilder ​

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 ​

Parameters:

  • action: the action to run when the button cycles
Returns: self for chaining.

alternateToggle ​

alternateToggle(MethodWrapper<?, ?, Boolean, ?> alternateToggle): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>Since1.8.4#
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.

alternatives ​

alternatives(T... values): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>Since1.8.4#
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.

createWidget ​

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 ​

getAction(): MethodWrapper<CyclingButtonWidgetHelper<T>, IScreen, Object, ?>Since1.8.4#
Returns: the configured action, or null if none is set

getAlternateToggle ​

getAlternateToggle(): MethodWrapper<?, ?, Boolean, ?>Since1.8.4#
Returns the toggle that selects the list during cycling, or null if none is configured.
Returns: the configured toggle, or null if unset.

getAlternateValues ​

getAlternateValues(): List<T>Since1.8.4#
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.

getDefaultValues ​

getDefaultValues(): List<T>Since1.8.4#
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.

getInitialValue ​

getInitialValue(): TSince1.8.4#
Returns: the configured initial value, or null if none was set

getOption ​

getOption(): TextHelperSince1.8.4#
Returns: the option prefix, or empty text if no option was set

getValueToText ​

getValueToText(): MethodWrapper<T, ?, TextHelper, ?>Since1.8.4#
Returns: the function used to convert values to button text

initially ​

initially(T value): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>Since1.8.4#
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.

isOptionTextOmitted ​

isOptionTextOmitted(): booleanSince1.8.4#
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.

omitTextOption ​

omitTextOption(boolean optionTextOmitted): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>Since1.8.4#
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.

option ​

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

values ​

values(T... values): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>Since1.8.4#
Replaces the default values; the alternate values are unchanged.

Parameters:

  • values: the default values of the button
Returns: self for chaining.
values(T[] defaults, T[] alternatives): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>Since1.8.4#
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.
values(List<T> defaults, List<T> alternatives): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>Since1.8.4#
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.

valueToText ​

valueToText(MethodWrapper<T, ?, TextHelper, ?> valueToText): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>Since1.8.4#

Parameters:

  • valueToText: the non-null function used to render each value as button text
Returns: self for chaining.