SubMenu Option
SubMenuOption Class
General Summary
SubMenuOption integrates a sub-menu alongside a toggleable button, enhancing the DynamicHUD with nested menu functionality.
Constructor Parameters
SubMenu Option offers 2 constructors like BooleanOption and RunnableOption.
name: The display name for the sub-menu option.parentMenu: The parentContextMenuto which this sub-menu belongs.getter: Supplier that determines if the sub-menu is displayed by default.setter: Consumer that updates the visibility state of the sub-menu.
The SubMenu just like BooleanOption and RunnableOption also supports BooleanPool in its second constructor where you dont have to put the getter and setter.
Interactivity
Click: Toggles the visibility of the sub-menu and updates its state.
Render: Shows the option's name and renders the sub-menu adjacent to the parent menu.
Rendering
Color Coding: The option's text color changes based on its state (green for visible, red for hidden).
Sub-Menu Positioning: The sub-menu is positioned beside the parent menu, aligned with the selected option.
Example Usage
ContextMenu mainMenu = new ContextMenu(100, 100);
SubMenuOption settingsOption = new SubMenuOption(
"Settings",
mainMenu,
() -> userPreferences.isSettingsMenuVisible(), // Getter
visible -> userPreferences.setSettingsMenuVisible(visible) // Setter
);
// Populate the sub-menu with options
settingsOption.getSubMenu().addOption(/* ... */);Last updated
Was this helpful?