DynamicHUD Dev Guide
DownloadNeed Support?
  • Dynamic HUD
  • Import using Gradle
  • Integrating DynamicHUD
    • Integrating DynamicHUD
    • Adding Widgets
    • Adding your own WidgetRenderer
    • Passing AbstractMoveableScreen instance
    • Changing default key bind
    • Changing save and load file
    • Registering Custom Widgets
  • Widget
    • Widget class
    • How to create a custom widget
    • Widget Renderer
    • WidgetData
    • DynamicValueRegistry
    • Scaling
  • Screens
    • AbstractMoveableScreen
  • ContextMenu
    • ContextMenu class
    • Using context menu
    • Option<T> class
      • Color Option
      • Boolean Option
      • Double Option
      • Runnable Option
      • Enum Option
      • List Option
      • SubMenu Option
Powered by GitBook
On this page
  • Introduction
  • Constructor
  • Behavior
  • Example

Was this helpful?

  1. ContextMenu
  2. Option<T> class

List Option

Introduction

ListOption cycles through a list of values, providing interactive selection.

Constructor

  • ListOption(String name, Supplier<T> getter, Consumer<T> setter, List<T> values)

Behavior

  • Click: Left-click advances, right-click reverses through the list.

  • Render: Shows the option's name and current value with distinct coloring.

Example

List<String> colorOptions = Arrays.asList("Red", "Green", "Blue");
ListOption<String> colorListOption = new ListOption<>(
    "Color",
    () -> config.getSelectedColor(),
    value -> config.setSelectedColor(value),
    colorOptions
);

Ensure that the getter is synchronized with the setter; otherwise, the option will enter a soft lock, and the value will not update. (Meaning the getter and setter are updating the same variables or referencing the same variable)

PreviousEnum OptionNextSubMenu Option

Last updated 1 year ago

Was this helpful?