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 Parameters
  • Interactivity
  • Example Usage

Was this helpful?

  1. ContextMenu
  2. Option<T> class

Runnable Option

Introduction

RunnableOption is a option class that encapsulates a task to be executed upon user interaction, specifically designed for actions that need to be triggered. This essentially acts as a boolean option but runs a task everytime the "boolean" is true.

Constructor Parameters

The RunnableOption class has two constructors that takes the following parameters:

  • One of the constructors uses the BooleanPool class to store and manage the Boolean values. This is when you don't want the hassle to create a new and unnecessary Boolean for every Runnable Option you create. This constructor does not contain the getter and setter variables.

  • name: Display name for the option.

  • getter: Supplier that checks if the task is currently considered active or running.

  • setter: Consumer that updates the task's active state based on user interaction.

  • task: The Runnable task to be executed.

Interactivity

  • Click: Toggles the task's active state and runs the task if set to active.

  • Render: Displays the option's name with a color change to indicate the active state.

Example Usage

RunnableOption resetOption = new RunnableOption(
    "Reset",
    () -> this.isDefaultValue(),
    shouldSet-> this.setDefaultValue(shouldSet),
    () -> connection.setDefault() // Task: Attempts to default
);
PreviousDouble OptionNextEnum Option

Last updated 9 months ago

Was this helpful?