ContextMenu class
This page talks about ContextMenu class
This page talks about ContextMenu class
The class provides functionality for creating and displaying menus on the screen
Here is the documentation for the ContextMenu
class in the requested format:
ContextMenu
The ContextMenu
class represents a context menu that can be displayed on the screen.
client
: The Minecraft client instance.
options
: The list of options in the context menu.
selectedWidget
: The widget that this context menu is associated with.
parentScreen
: The parent screen of this context menu.
width
: The width of the context menu.
x
: The x position of the context menu.
y
: The y position of the context menu.
backgroundColor
: The background color of the context menu.
padding
: The amount of padding around the rectangle.
HeightFromWidget
: The amount of padding around the rectangle.
scale
: The scale of the context menu.
height
: The height of the context menu.
dataInputValue
: The value entered in a data input option.
doubleInputValue
: The value entered in a double input option.
ContextMenu(MinecraftClient client, int x, int y, Widget selectedWidget, Screen parentScreen)
: Constructs a ContextMenu object with the given Minecraft client instance, position, selected widget and parent screen.
addOption(String label, Runnable action)
: Adds an option to the context menu with the given label and action.
addDataTextOption(String label, Consumer<String> action,int WidgetX, int WidgetY)
: Adds a data text option to the context menu with the given label and action.
addDoubleTextOption(String label, Consumer<Double> action, int WidgetX, int WidgetY)
: Adds a double text option to the context menu with the given label and action.
setBackgroundColor(int backgroundColor)
: Sets the background color of this context menu.
contains(double x, double y)
: Returns whether the given point is within the bounds of this context menu.
getX()
, getY()
, getWidth()
, getParentScreen()
, getSelectedWidget()
, getScale()
, getHeight()
, and other getter methods: Returns various properties of this context menu.
<T extends Enum<T>> void addEnumCycleOption(String labelPrefix, T[] values, Supplier<T> getter, Consumer<T> setter)
: Adds an option to the context menu that cycles through the values of an Enum.
tick()
, updatePosition()
, and other methods: Updates various properties of this context menu.
Inner classes the following inner classes are defined within the ContextMenu class:
ContextMenuOption
The ContextMenuOption class represents an option in a ContextMenu.
action
: The action to perform when this option is clicked.
label
: The label of this option.
enabled
: Whether this option is enabled.
ContextMenuOption(String label, Runnable action)
: Constructs a ContextMenuOption object with the given label and action.
Methods Various getter and setter methods for accessing and modifying properties of this object.
EnumCycleContextMenuOption
The EnumCycleContextMenuOption class extends ContextMenuOption and represents an option in a ContextMenu that cycles through values of an enum.Fields Inherits fields from ContextMenuOption. Also has additional fields for storing information about the enum values.
Constructors Inherits constructors from ContextMenuOption. Also has additional constructors for initializing enum-specific properties.
Methods Inherits methods from ContextMenuOption. Also has additional methods for updating properties specific to enum options.
DataInputOption
The DataInputOption class extends ContextMenuOption and represents an option in a ContextMenu that allows entering data.Fields Inherits fields from ContextMenuOption. Also has additional fields for storing information about data input.
Constructors Inherits constructors from ContextMenuOption. Also has additional constructors for initializing data input-specific properties.
Methods Inherits methods from ContextMenuOption. Also has additional methods for updating properties specific to data input options.
DoubleInputOption
The DoubleInputOption class extends ContextMenuOption and represents an option in a ContextMenu that allows entering double values.Fields Inherits fields from ContextMenuOption. Also has additional fields for storing information about double input.
Constructors Inherits constructors from ContextMenuOption. Also has additional constructors for initializing double input-specific properties.
Methods Inherits methods from ContextMenuOption. Also has additional methods for updating properties specific to double input options.
I hope this helps! Let me know if you need any further information or clarification.