Class Dropdown.Builder<T>

java.lang.Object
dev.xichil.mvui.Entry.Builder<Dropdown.Builder<T>>
dev.xichil.mvui.Dropdown.Builder<T>
Type Parameters:
T - the value type
Enclosing class:
Dropdown<T>

public static final class Dropdown.Builder<T> extends Entry.Builder<Dropdown.Builder<T>>
Builds a Dropdown; from Dropdown.builder(String). The same setters as Cycle.Builder, plus the options every entry has (Entry.Builder).
  • Method Details

    • label

      public Dropdown.Builder<T> label(Supplier<Text> label)
      The text before ": value" and the picker's title, re-read on every refresh. Required.
      Parameters:
      label - read on refresh
      Returns:
      this builder
    • label

      public Dropdown.Builder<T> label(Text label)
      A fixed label; see label(Supplier).
      Parameters:
      label - the label
      Returns:
      this builder
    • values

      public Dropdown.Builder<T> values(List<T> values)
      The values the picker lists, in order. Required, not empty. Copied at build time: to offer a list that changes, build the screen again (e.g. reopen it).
      Parameters:
      values - the values; must implement Object.equals(Object) consistently
      Returns:
      this builder
    • value

      public Dropdown.Builder<T> value(Supplier<T> value)
      Reads the mod's current value; re-read on every refresh. Required. A value not in values shows as the first one.
      Parameters:
      value - reads the current value
      Returns:
      this builder
    • valueText

      public Dropdown.Builder<T> valueText(Function<? super T, Text> valueText)
      How a value is shown on the button and in the picker's rows. Required.
      Parameters:
      valueText - maps a value to its text; never returns null
      Returns:
      this builder
    • onChange

      public Dropdown.Builder<T> onChange(Consumer<? super T> onChange)
      Stores the picked value; runs on the main thread after the picker has closed. Required.
      Parameters:
      onChange - receives the picked value
      Returns:
      this builder
    • build

      public Dropdown<T> build()
      Builds the dropdown.
      Returns:
      the dropdown
      Throws:
      IllegalStateException - if a required field is missing or values is empty