Archived Legacy DynamicHUD
  • Dynamic HUD
  • Import using Gradle
  • Widgets
    • Adding Widgets
      • TextWidget
      • ItemWidget
      • ArmorWidget
    • Creating your own Widget class
    • Widget class
    • WidgetManager
    • WidgetBox
  • Saving and Loading
    • Saving and Loading
    • Changing save file name and directory
  • Moveable Screen
    • AbstractMoveableScreen
    • Default Moveable Screen
    • Using the default Moveable Screen
    • Creating and using your own MoveableScreen class
  • ContextMenu
    • ContextMenu class
    • ContextMenuOptionsProvider interface
    • DoubleInputScreen
    • DataInputScreen
  • Slider Widget
    • Slider
  • SliderWidgetBuilder
  • ColorPicker
    • ColorGradientPicker
      • ColorPickerButton
      • GradientBox
      • GradientSlider
  • Helpers
    • ColorHelper
    • DrawHelper
    • TextureHelper
Powered by GitBook
On this page
  1. ContextMenu

ContextMenuOptionsProvider interface

This page talks about ContextMenuOptionsProvider interface

PreviousContextMenu classNextDoubleInputScreen

The interface defines a single method, isOptionEnabled, which takes a label as an argument and returns a boolean indicating whether the option with the given label is enabled or not.

This interface is used by the ContextMenu class to determine whether an option in the context menu should be enabled or disabled. When adding an option to the context menu, the ContextMenu class checks if the selected widget is an instance of ContextMenuOptionsProvider. If it is, the ContextMenu class calls the isOptionEnabled method on the selected widget to determine whether the option should be enabled or not.

In the textWidget class, There is an implementation of the isOptionEnabled method that returns different values depending on the label of the option. For example, if the label is "Shadow", this method returns the value of the hasShadow method. This allows you to control which options in the context menu are enabled or disabled based on the state of your widget.

Example:

 @Override
    public boolean isOptionEnabled(String label) {
        return switch (label) {
            case "Shadow" -> hasShadow();
            case "Rainbow" -> hasRainbow();
            case "Vertical Rainbow" -> hasVerticalRainbow();
            case "TextColor" -> isTextcolorOptionEnabled();
            case "DataColor" -> isDatacolorOptionEnabled();
            default -> false;
        };
    }
ContextMenuOptionsProvider