Class Entry.Builder<B extends Entry.Builder<B>>

java.lang.Object
dev.xichil.mvui.Entry.Builder<B>
Type Parameters:
B - the concrete builder type, returned by every setter
Direct Known Subclasses:
Button.Builder, Checkbox.Builder, ColorPicker.Builder, Cycle.Builder, Dropdown.Builder, Keybind.Builder, Label.Builder, MultiLineInput.Builder, NumberField.Builder, Section.Builder, SelectList.Builder, Slider.Builder, StatusLine.Builder, TextInput.Builder, Toggle.Builder
Enclosing class:
Entry

public abstract static class Entry.Builder<B extends Entry.Builder<B>> extends Object
The options every entry builder has. Each widget's builder extends it, so these setters chain with the widget's own (Toggle.builder("x").label(…).enabled(…).build()) and return that builder type.

Every setter that takes a supplier also has a constant overload; the supplier form is re-read on every refresh. A required field that is missing or null makes build() throw IllegalStateException naming the widget and the field; setters of optional fields reject null at once, with the same exception.

  • Method Details

    • enabled

      public B enabled(BooleanSupplier enabled)
      Whether the widget can be used, re-read on every refresh. While false it is drawn greyed out and ignores input; it still shows its label, value and tooltip. Default: always enabled.
      Parameters:
      enabled - read on refresh
      Returns:
      this builder
    • enabled

      public B enabled(boolean enabled)
      A fixed enabled state; see enabled(BooleanSupplier).
      Parameters:
      enabled - false to grey the widget out for good
      Returns:
      this builder
    • tooltip

      public B tooltip(Supplier<Text> tooltip)
      The tooltip shown while the mouse is over the widget, re-read on every refresh; the supplier may return null for no tooltip at that moment. Disabled widgets show their tooltip too, which makes it a good place to say why something is disabled. Default: none.
      Parameters:
      tooltip - read on refresh; returns null for none
      Returns:
      this builder
    • tooltip

      public B tooltip(Text tooltip)
      A fixed tooltip; see tooltip(Supplier).
      Parameters:
      tooltip - the tooltip, or null for none
      Returns:
      this builder
    • visible

      public B visible(BooleanSupplier visible)
      Shows the entry only while visible is true, re-read on every refresh. A hidden entry takes no space: the rows below move up. Use it for options that only apply in some state:
      .add(Slider.builder("fogDistance")…
              .visible(() -> config.fog)
              .build())
      
      An entry with a visible supplier can't be in a MenuScreen's footer. To hide a group of entries together, put them in a collapsible Section instead; a section hides its children by itself.
      Parameters:
      visible - read on refresh
      Returns:
      this builder