Class GuiContextMenu
java.lang.Object
codechicken.lib.gui.modular.lib.geometry.ConstrainedGeometry<GuiContextMenu>
codechicken.lib.gui.modular.elements.GuiElement<GuiContextMenu>
codechicken.lib.gui.modular.elements.GuiContextMenu
- All Implemented Interfaces:
ElementEvents,GuiParent<GuiContextMenu>,TooltipHandler<GuiContextMenu>
Context menus get added to the root element when they are created so as long as no new elements are added after the menu is opened,
the menu will always be on top.
It will also automatically close when an option is selected, or when the user clicks outside the context menu.
Created by brandon3055 on 21/11/2023
-
Field Summary
Fields inherited from class codechicken.lib.gui.modular.elements.GuiElement
hoverTime, initialized -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBy default, the option action fires on mouse button release (like pretty much any UI button in existence) Calling this will change that to action on mouse button press, (What minecraft uses for its buttons)addOption(Supplier<net.minecraft.network.chat.Component> label, Runnable action, net.minecraft.network.chat.Component... tooltip) addOption(Supplier<net.minecraft.network.chat.Component> label, Supplier<List<net.minecraft.network.chat.Component>> tooltip, Runnable action) addOption(Supplier<net.minecraft.network.chat.Component> label, List<net.minecraft.network.chat.Component> tooltip, Runnable action) voidclose()booleanmouseClicked(double mouseX, double mouseY, int button, boolean consumed) Root handler for mouseClick event.booleanmouseReleased(double mouseX, double mouseY, int button, boolean consumed) Root handler for mouseReleased event.setButtonBuilder(BiFunction<GuiContextMenu, Supplier<net.minecraft.network.chat.Component>, GuiButton> buttonBuilder) Only height should be constrained, with will be set automatically to accommodate the provided label.setCloseOnItemClicked(boolean closeOnItemClicked) setCloseOnOutsideClick(boolean closeOnOutsideClick) setNormalizedPos(double x, double y) static GuiContextMenutooltipStyleMenu(GuiParent<?> parent) Methods inherited from class codechicken.lib.gui.modular.elements.GuiElement
addChild, addJeiDropTargets, addJeiExclusions, adoptChild, applyQueuedChildUpdates, blockMouseEvents, blockMouseOver, bringChildToForeground, font, getChildren, getCombinedElementDepth, getJeiDropConsumer, getModularGui, getParent, getTooltip, getTooltipDelay, hoverTime, initElement, isDescendantOf, isEnabled, isJeiDropTarget, isJeiExcluded, isMouseOver, isOpaque, isRemoved, isTooltipEnabled, jeiExclude, mc, onScreenInit, removeChild, render, renderChild, renderOverlay, scaledScreenHeight, scaledScreenWidth, sendChildToBackground, sendChildToIndex, setEnabled, setEnabled, setEnableToolTip, setJeiDropTarget, setJeiExcluded, setOpaque, setRenderCull, setTooltip, setTooltipDelay, setZStacking, showToolTip, tick, toString, updateMouseOver, updateScreenData, zStackingMethods inherited from class codechicken.lib.gui.modular.lib.geometry.ConstrainedGeometry
addBoundsToRect, clearConstraints, clearGeometryCache, constrain, get, getChildBounds, getEnclosingRect, getParent, getPosition, getRectangle, placeInside, placeInside, placeOutside, placeOutside, setHeight, setPos, setSize, setWidth, setXPos, setYPos, strictMode, validate, xCenter, xMax, xMin, xSize, yCenter, yMax, yMin, ySizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface codechicken.lib.gui.modular.lib.ElementEvents
charTyped, charTyped, keyPressed, keyPressed, keyReleased, keyReleased, mouseClicked, mouseMoved, mouseReleased, mouseScrolled, mouseScrolledMethods inherited from interface codechicken.lib.gui.modular.lib.geometry.GuiParent
addChild, getValueMethods inherited from interface codechicken.lib.gui.modular.lib.TooltipHandler
renderTooltip, setTooltip, setTooltip, setTooltip, setTooltipSingle, setTooltipSingle
-
Constructor Details
-
GuiContextMenu
-
-
Method Details
-
tooltipStyleMenu
-
setCloseOnItemClicked
-
setCloseOnOutsideClick
-
actionOnClick
By default, the option action fires on mouse button release (like pretty much any UI button in existence) Calling this will change that to action on mouse button press, (What minecraft uses for its buttons) -
setButtonBuilder
public GuiContextMenu setButtonBuilder(BiFunction<GuiContextMenu, Supplier<net.minecraft.network.chat.Component>, GuiButton> buttonBuilder) Only height should be constrained, with will be set automatically to accommodate the provided label. -
addOption
public GuiContextMenu addOption(Supplier<net.minecraft.network.chat.Component> label, Runnable action) -
addOption
public GuiContextMenu addOption(Supplier<net.minecraft.network.chat.Component> label, Supplier<List<net.minecraft.network.chat.Component>> tooltip, Runnable action) -
addOption
public GuiContextMenu addOption(Supplier<net.minecraft.network.chat.Component> label, List<net.minecraft.network.chat.Component> tooltip, Runnable action) -
addOption
public GuiContextMenu addOption(Supplier<net.minecraft.network.chat.Component> label, Runnable action, net.minecraft.network.chat.Component... tooltip) -
mouseClicked
public boolean mouseClicked(double mouseX, double mouseY, int button, boolean consumed) Description copied from interface:ElementEventsRoot handler for mouseClick event. This method will always be called for all elements even if the event has already been consumed. There are a few uses for this method, but the fast majority of mouseClick handling should be implemented viaElementEvents.mouseClicked(double, double, int)Note: If overriding this method, do so with caution, You must either return true (if you wish to consume the event) or you must return the result of the super call.
- Parameters:
mouseX- Mouse X positionmouseY- Mouse Y positionbutton- Mouse Buttonconsumed- Will be true if this action has already been consumed.- Returns:
- true if this event has been consumed.
-
mouseReleased
public boolean mouseReleased(double mouseX, double mouseY, int button, boolean consumed) Description copied from interface:ElementEventsRoot handler for mouseReleased event. This method will always be called for all elements even if the event has already been consumed. There are a few uses for this method, but the fast majority of mouseReleased handling should be implemented viaElementEvents.mouseReleased(double, double, int)Note: If overriding this method, do so with caution, You must either return true (if you wish to consume the event) or you must return the result of the super call.
- Parameters:
mouseX- Mouse X positionmouseY- Mouse Y positionbutton- Mouse Buttonconsumed- Will be true if this action has already been consumed.- Returns:
- true if this event has been consumed.
-
close
public void close() -
setNormalizedPos
-