CyclingButtonWidgetHelper.CyclicButtonBuilder
com.jsmacrosce.jsmacros.client.api.helper.screen.CyclingButtonWidgetHelper.CyclicButtonBuilder
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 buildervalueToText: the function converting values to non-null display text
Methods
action
action(MethodWrapper<CyclingButtonWidgetHelper<T>, IScreen, Object, ?> action): CyclingButtonWidgetHelper.CyclicButtonBuilder<T>Since1.8.4#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
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
Returns: the configured action, or
null if none is setgetAlternateToggle
Returns the toggle that selects the list during cycling, or
null if none is configured.Returns: the configured toggle, or
null if unset.getAlternateValues
getDefaultValues
getInitialValue
Returns: the configured initial value, or
null if none was setgetOption
Returns: the option prefix, or empty text if no option was set
getValueToText
Returns: the function used to convert values to button text
initially
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
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
Replaces the default values; the alternate values are unchanged.
Parameters:
values: the default values of the button
Returns: self for chaining.
Sets the default and alternate values, replacing both lists while leaving the toggle unchanged.
Parameters:
defaults: the default values of the buttonalternatives: 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 buttonalternatives: 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.