Class AutoComplete<T>
java.lang.Object
net.minecraft.client.gui.components.AbstractWidget
com.blamejared.searchables.api.autcomplete.AutoComplete<T>
- Type Parameters:
T- The type of element that is being searched for.
- All Implemented Interfaces:
Consumer<String>,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 AutoComplete<T>
extends net.minecraft.client.gui.components.AbstractWidget
implements Consumer<String>
A small widget that displays current suggestions for an
AutoCompletingEditBox<T>.-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.client.gui.narration.NarratableEntry
net.minecraft.client.gui.narration.NarratableEntry.NarrationPriority -
Field Summary
Fields inherited from class net.minecraft.client.gui.components.AbstractWidget
active, alpha, height, isHovered, packedFGColor, UNSET_FG_COLOR, visible, width -
Constructor Summary
ConstructorsConstructorDescriptionAutoComplete(SearchableType<T> type, AutoCompletingEditBox<T> editBox, Supplier<List<T>> entries, int x, int y, int width, int suggestionHeight) Create a new AutoComplete with the given values and amaxSuggestionsize of 7AutoComplete(SearchableType<T> type, AutoCompletingEditBox<T> editBox, Supplier<List<T>> entries, int x, int y, int width, int suggestionHeight, int maxSuggestions) Create a new AutoComplete with the given values. -
Method Summary
Modifier and TypeMethodDescriptionvoidCompiles suggestions for the given value.editBox()voidInserts the currently selected suggestion into attachedAutoCompletingEditBox<T>.booleanisMouseOver(double xpos, double ypos) intbooleanmouseClicked(net.minecraft.client.input.MouseButtonEvent event, boolean doubleClick) booleanmouseScrolled(double xpos, double ypos, double xDelta, double yDelta) voidrenderWidget(net.minecraft.client.gui.GuiGraphics guiGraphics, int mx, int my, float partial) voidScrolls the current suggestions down by 1.voidscrollDown(int amount) Scrolls the current suggestions down by the given amount.voidscrollUp()Scrolls the current suggestions up by 1.voidscrollUp(int amount) Scrolls the current suggestions up by the given amount.protected voidupdateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput output) Methods inherited from class net.minecraft.client.gui.components.AbstractWidget
clearFGColor, createNarrationMessage, defaultButtonNarrationText, getBottom, getFGColor, getHeight, getMessage, getRectangle, getRight, getTabOrderGroup, getWidth, getX, getY, isActive, isFocused, isHovered, isHoveredOrFocused, isValidClickButton, mouseDragged, mouseReleased, narrationPriority, nextFocusPath, onClick, onDrag, onRelease, playButtonClickSound, playDownSound, render, renderScrollingString, renderScrollingString, renderScrollingString, setAlpha, setFGColor, setFocused, setHeight, setMessage, setRectangle, setSize, setTabOrderGroup, setTooltip, setTooltipDelay, setWidth, setX, setY, updateNarration, visitWidgets, wrapDefaultNarrationMessageMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.client.gui.components.events.GuiEventListener
charTyped, getBorderForArrowNavigation, getCurrentFocusPath, keyPressed, keyReleased, mouseMoved, shouldTakeFocusAfterInteractionMethods inherited from interface net.minecraft.client.gui.layouts.LayoutElement
setPositionMethods inherited from interface net.minecraft.client.gui.narration.NarratableEntry
getNarratables
-
Constructor Details
-
AutoComplete
public AutoComplete(SearchableType<T> type, AutoCompletingEditBox<T> editBox, Supplier<List<T>> entries, int x, int y, int width, int suggestionHeight) Create a new AutoComplete with the given values and amaxSuggestionsize of 7- Parameters:
type- TheSearchableType<T>that thisAutoComplete<T>completes for.editBox- The attachedAutoCompletingEditBox<T>that thisAutoComplete<T>is attached to.entries- The entries that should be used for completion.x- The x position of this widget on the screen.y- The y position of this widget on the screen.width- The width of this widget on the screen.suggestionHeight- The height of each individual suggestion. Recommended to beFont#lineHeight + 2
-
AutoComplete
public AutoComplete(SearchableType<T> type, AutoCompletingEditBox<T> editBox, Supplier<List<T>> entries, int x, int y, int width, int suggestionHeight, int maxSuggestions) Create a new AutoComplete with the given values.- Parameters:
type- TheSearchableType<T>that thisAutoComplete<T>completes for.editBox- The attachedAutoCompletingEditBox<T>that thisAutoComplete<T>is attached to.entries- The entries that should be used for completion.x- The x position of this widget on the screen.y- The y position of this widget on the screen.width- The width of this widget on the screen.suggestionHeight- The height of each individual suggestion.maxSuggestions- How many suggestions to show.
-
-
Method Details
-
accept
Compiles suggestions for the given value. -
isMouseOver
public boolean isMouseOver(double xpos, double ypos) - Specified by:
isMouseOverin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
isMouseOverin classnet.minecraft.client.gui.components.AbstractWidget
-
mouseScrolled
public boolean mouseScrolled(double xpos, double ypos, double xDelta, double yDelta) - Specified by:
mouseScrolledin interfacenet.minecraft.client.gui.components.events.GuiEventListener
-
mouseClicked
public boolean mouseClicked(net.minecraft.client.input.MouseButtonEvent event, boolean doubleClick) - Specified by:
mouseClickedin interfacenet.minecraft.client.gui.components.events.GuiEventListener- Overrides:
mouseClickedin classnet.minecraft.client.gui.components.AbstractWidget
-
insertSuggestion
public void insertSuggestion()Inserts the currently selected suggestion into attachedAutoCompletingEditBox<T>. -
renderWidget
public void renderWidget(net.minecraft.client.gui.GuiGraphics guiGraphics, int mx, int my, float partial) - Specified by:
renderWidgetin classnet.minecraft.client.gui.components.AbstractWidget
-
scrollUp
public void scrollUp()Scrolls the current suggestions up by 1. -
scrollUp
public void scrollUp(int amount) Scrolls the current suggestions up by the given amount.- Parameters:
amount- The amount to scroll by.
-
scrollDown
public void scrollDown()Scrolls the current suggestions down by 1. -
scrollDown
public void scrollDown(int amount) Scrolls the current suggestions down by the given amount.- Parameters:
amount- The amount to scroll by.
-
maxSuggestions
public int maxSuggestions() -
editBox
-
updateWidgetNarration
protected void updateWidgetNarration(net.minecraft.client.gui.narration.NarrationElementOutput output) - Specified by:
updateWidgetNarrationin classnet.minecraft.client.gui.components.AbstractWidget
-