Class DropDownWidget<T>
java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
net.minecraft.client.gui.components.AbstractScrollWidget
com.pixelmonmod.pixelmon.client.gui.npc.widget.DropDownWidget<T>
- All Implemented Interfaces:
net.minecraft.client.gui.components.events.GuiEventListener
,net.minecraft.client.gui.components.Renderable
,net.minecraft.client.gui.components.TabOrderedElement
,net.minecraft.client.gui.layouts.LayoutElement
,net.minecraft.client.gui.narration.NarratableEntry
,net.minecraft.client.gui.narration.NarrationSupplier
public class DropDownWidget<T>
extends net.minecraft.client.gui.components.AbstractScrollWidget
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.client.gui.narration.NarratableEntry
net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected net.minecraft.client.gui.components.EditBox
protected it.unimi.dsi.fastutil.booleans.BooleanConsumer
static final int
protected T
Fields inherited from class net.minecraft.client.gui.components.AbstractScrollWidget
scrollAmount, scrolling
Fields inherited from class net.minecraft.client.gui.components.AbstractWidget
alpha, focused, height, hoverOrFocusedStartTime, isHovered, message, MIN_SCROLL_PERIOD, packedFGColor, PERIOD_PER_SCROLLED_PIXEL, tabOrderGroup, tooltip, tooltipMsDelay, UNSET_FG_COLOR, wasHoveredOrFocused, width, x, y
Fields inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
DOUBLE_CLICK_THRESHOLD_MS
-
Constructor Summary
ConstructorDescriptionDropDownWidget
(int width, int height) DropDownWidget
(int x, int y, int width, int height) -
Method Summary
Modifier and TypeMethodDescriptionboolean
charTyped
(char character, int modifiers) protected String
convertOption
(T option) protected T
findElementFor
(double mouseX, double mouseY) Finds the row in the list that the cursor is hovering over.int
protected int
protected int
int
getWidth()
boolean
isMouseOver
(double mouseX, double mouseY) boolean
keyPressed
(int keyCode, int scanCode, int modifiers) boolean
mouseClicked
(double mouseX, double mouseY, int button) boolean
mouseDragged
(double mouseX, double mouseY, int button, double deltaX, double deltaY) void
onClick
(double mouseX, double mouseY) protected void
renderBackground
(net.minecraft.client.gui.GuiGraphics graphics) protected void
renderContents
(net.minecraft.client.gui.GuiGraphics gui, int mouseX, int mouseY, float partialTicks) Renders the list of options that opens up (aka that drops-down) upon opening the drop-down.protected void
renderDecorations
(net.minecraft.client.gui.GuiGraphics p_283178_) void
renderWidget
(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) protected boolean
protected double
void
setMaxVisibleOptions
(int maxNumberOfOptions) Sets the maximum number of the drop-down's contents that will be displayed upon opening it up.void
setOnDropDownToggle
(it.unimi.dsi.fastutil.booleans.BooleanConsumer onDropDownToggle) setOnSelected
(Consumer<T> onSelected) setOptionConverter
(Function<T, String> optionConverter) void
setOptions
(List<T> options, T selected) void
setSelected
(T selected) void
setWidth
(int value) protected void
updateWidgetNarration
(net.minecraft.client.gui.narration.NarrationElementOutput p_259858_) Methods inherited from class net.minecraft.client.gui.components.AbstractScrollWidget
innerPadding, mouseReleased, mouseScrolled, renderBorder, scrollAmount, scrollbarWidth, setScrollAmount, totalInnerPadding, withinContentAreaPoint, withinContentAreaTopBottom
Methods inherited from class net.minecraft.client.gui.components.AbstractWidget
clearFGColor, clicked, createNarrationMessage, createTooltipPositioner, defaultButtonNarrationText, getFGColor, getMessage, getRectangle, getTabOrderGroup, getTooltip, getX, getY, isActive, isFocused, isHovered, isHoveredOrFocused, isValidClickButton, narrationPriority, nextFocusPath, onDrag, onRelease, playDownSound, render, renderScrollingString, renderScrollingString, renderScrollingString, setAlpha, setFGColor, setFocused, setHeight, setMessage, setTabOrderGroup, setTooltip, setTooltipDelay, setX, setY, updateNarration, visitWidgets, wrapDefaultNarrationMessage
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
getCurrentFocusPath, getRectangle, isFocused, keyReleased, mouseMoved, nextFocusPath, setFocused
Methods inherited from interface net.minecraft.client.gui.layouts.LayoutElement
setPosition
Methods inherited from interface net.minecraft.client.gui.components.Renderable
render
Methods inherited from interface net.minecraft.client.gui.components.TabOrderedElement
getTabOrderGroup
-
Field Details
-
OPTION_HEIGHT
public static final int OPTION_HEIGHT- See Also:
-
editBox
protected net.minecraft.client.gui.components.EditBox editBox -
originalOptions
-
options
-
selectedOption
-
onSelected
-
onDropDownToggle
protected it.unimi.dsi.fastutil.booleans.BooleanConsumer onDropDownToggle -
optionConverter
-
active
protected boolean active
-
-
Constructor Details
-
DropDownWidget
public DropDownWidget(int width, int height) -
DropDownWidget
public DropDownWidget(int x, int y, int width, int height)
-
-
Method Details
-
setOptions
-
setWidth
public void setWidth(int value) - Overrides:
setWidth
in classnet.minecraft.client.gui.components.AbstractWidget
-
setSelected
-
setOptionConverter
-
setOnSelected
-
setOrdered
-
setOnDropDownToggle
public void setOnDropDownToggle(it.unimi.dsi.fastutil.booleans.BooleanConsumer onDropDownToggle) -
getSelected
-
scrollRate
protected double scrollRate()- Specified by:
scrollRate
in classnet.minecraft.client.gui.components.AbstractScrollWidget
-
renderWidget
public void renderWidget(net.minecraft.client.gui.GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) - Overrides:
renderWidget
in classnet.minecraft.client.gui.components.AbstractScrollWidget
-
renderDecorations
protected void renderDecorations(net.minecraft.client.gui.GuiGraphics p_283178_) - Overrides:
renderDecorations
in classnet.minecraft.client.gui.components.AbstractScrollWidget
-
findElementFor
Finds the row in the list that the cursor is hovering over.- Parameters:
mouseX
- The cursor's x coordinates.mouseY
- The cursor's y coordinates.- Returns:
- The element in the drop-down's list of options that the cursor is hovering over.
-
renderContents
protected void renderContents(net.minecraft.client.gui.GuiGraphics gui, int mouseX, int mouseY, float partialTicks) Renders the list of options that opens up (aka that drops-down) upon opening the drop-down.- Specified by:
renderContents
in classnet.minecraft.client.gui.components.AbstractScrollWidget
- Parameters:
gui
- The PoseStack matrixmouseX
- The cursor's x position.mouseY
- The cursor's y position.partialTicks
- The number of partial ticks that have elapsed.
-
renderBackground
protected void renderBackground(net.minecraft.client.gui.GuiGraphics graphics) - Overrides:
renderBackground
in classnet.minecraft.client.gui.components.AbstractScrollWidget
-
mouseClicked
public boolean mouseClicked(double mouseX, double mouseY, int button) - Specified by:
mouseClicked
in interfacenet.minecraft.client.gui.components.events.GuiEventListener
- Overrides:
mouseClicked
in classnet.minecraft.client.gui.components.AbstractScrollWidget
-
onClick
public void onClick(double mouseX, double mouseY) - Overrides:
onClick
in classnet.minecraft.client.gui.components.AbstractWidget
-
mouseDragged
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) - Specified by:
mouseDragged
in interfacenet.minecraft.client.gui.components.events.GuiEventListener
- Overrides:
mouseDragged
in classnet.minecraft.client.gui.components.AbstractScrollWidget
-
keyPressed
public boolean keyPressed(int keyCode, int scanCode, int modifiers) - Specified by:
keyPressed
in interfacenet.minecraft.client.gui.components.events.GuiEventListener
- Overrides:
keyPressed
in classnet.minecraft.client.gui.components.AbstractScrollWidget
-
charTyped
public boolean charTyped(char character, int modifiers) -
updateWidgetNarration
protected void updateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput p_259858_) - Specified by:
updateWidgetNarration
in classnet.minecraft.client.gui.components.AbstractWidget
-
convertOption
-
getInnerHeight
protected int getInnerHeight()- Specified by:
getInnerHeight
in classnet.minecraft.client.gui.components.AbstractScrollWidget
-
scrollbarVisible
protected boolean scrollbarVisible()- Overrides:
scrollbarVisible
in classnet.minecraft.client.gui.components.AbstractScrollWidget
-
getMaxScrollAmount
protected int getMaxScrollAmount()- Overrides:
getMaxScrollAmount
in classnet.minecraft.client.gui.components.AbstractScrollWidget
-
getHeight
public int getHeight()- Specified by:
getHeight
in interfacenet.minecraft.client.gui.layouts.LayoutElement
- Overrides:
getHeight
in classnet.minecraft.client.gui.components.AbstractWidget
-
isMouseOver
public boolean isMouseOver(double mouseX, double mouseY) - Specified by:
isMouseOver
in interfacenet.minecraft.client.gui.components.events.GuiEventListener
- Overrides:
isMouseOver
in classnet.minecraft.client.gui.components.AbstractWidget
-
getWidth
public int getWidth()- Specified by:
getWidth
in interfacenet.minecraft.client.gui.layouts.LayoutElement
- Overrides:
getWidth
in classnet.minecraft.client.gui.components.AbstractWidget
-
setMaxVisibleOptions
public void setMaxVisibleOptions(int maxNumberOfOptions) Sets the maximum number of the drop-down's contents that will be displayed upon opening it up.- Parameters:
maxNumberOfOptions
- The maximum items the drop-down should show.
-