public class WTextField extends WWidget
| Modifier and Type | Field and Description |
|---|---|
protected @Nullable BackgroundPainter |
backgroundPainter |
protected int |
cursor |
protected boolean |
editable |
protected int |
enabledColor |
protected int |
maxLength |
static int |
OFFSET_X_TEXT |
protected java.util.function.Consumer<java.lang.String> |
onChanged |
protected int |
select
If not -1, select is the "anchor point" of a selection.
|
protected @Nullable net.minecraft.text.Text |
suggestion |
protected java.lang.String |
text |
protected java.util.function.Predicate<java.lang.String> |
textPredicate |
protected int |
uneditableColor |
| Constructor and Description |
|---|
WTextField() |
WTextField(net.minecraft.text.Text suggestion) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canFocus()
Tests whether this widget can have the focus in the GUI.
|
boolean |
canResize()
Checks whether this widget can be resized using
WWidget.setSize(int, int). |
static int |
getCaretOffset(java.lang.String s,
int pos)
From a caret position, finds out what the x-offset to draw the caret is.
|
static int |
getCaretPos(java.lang.String s,
int x)
From an X offset past the left edge of a TextRenderer.draw, finds out what the closest caret
position (division between letters) is.
|
int |
getCursor() |
int |
getMaxLength() |
@Nullable java.lang.String |
getSelection() |
@Nullable net.minecraft.text.Text |
getSuggestion() |
java.lang.String |
getText() |
void |
insertText(int ofs,
java.lang.String s) |
boolean |
isEditable() |
void |
onCharTyped(char ch)
Notifies this widget that a character has been typed.
|
InputResult |
onClick(int x,
int y,
int button)
Notifies this widget that the mouse has been pressed and released, both while inside its bounds.
|
void |
onFocusGained()
Notifies this widget that it has gained focus
|
void |
onKeyPressed(int ch,
int key,
int modifiers)
Notifies this widget that a key has been pressed.
|
void |
paint(net.minecraft.client.util.math.MatrixStack matrices,
int x,
int y,
int mouseX,
int mouseY)
Paints this widget.
|
protected void |
renderTextField(net.minecraft.client.util.math.MatrixStack matrices,
int x,
int y) |
WTextField |
setBackgroundPainter(BackgroundPainter painter) |
WTextField |
setChangedListener(java.util.function.Consumer<java.lang.String> listener) |
void |
setCursorPos(int location) |
WTextField |
setDisabledColor(int col) |
WTextField |
setEditable(boolean editable) |
WTextField |
setEnabledColor(int col) |
WTextField |
setMaxLength(int max) |
void |
setSize(int x,
int y)
Sets the size of this widget.
|
WTextField |
setSuggestion(@Nullable java.lang.String suggestion) |
WTextField |
setSuggestion(@Nullable net.minecraft.text.Text suggestion) |
void |
setText(java.lang.String s) |
WTextField |
setTextPredicate(java.util.function.Predicate<java.lang.String> predicate_1) |
addPainters, addTooltip, createPeers, cycleFocus, getAbsoluteX, getAbsoluteY, getHeight, getHost, getParent, getWidth, getX, getY, hit, isActivationKey, isFocused, isWithinBounds, onFocusLost, onHidden, onKeyReleased, onMouseDown, onMouseDrag, onMouseMove, onMouseScroll, onMouseUp, onShown, releaseFocus, renderTooltip, requestFocus, setHost, setLocation, setParent, tick, validatepublic static final int OFFSET_X_TEXT
protected java.lang.String text
protected int maxLength
protected boolean editable
protected int enabledColor
protected int uneditableColor
@Nullable protected @Nullable net.minecraft.text.Text suggestion
protected int cursor
protected int select
protected java.util.function.Consumer<java.lang.String> onChanged
protected java.util.function.Predicate<java.lang.String> textPredicate
@Environment(value=CLIENT) @Nullable protected @Nullable BackgroundPainter backgroundPainter
public WTextField()
public WTextField(net.minecraft.text.Text suggestion)
public void setText(java.lang.String s)
public java.lang.String getText()
public boolean canResize()
WWidgetWWidget.setSize(int, int).public void setSize(int x,
int y)
WWidgetOverriding methods may restrict one of the dimensions to be
a constant value, for example super.setSize(x, 20).
public void setCursorPos(int location)
public int getMaxLength()
public int getCursor()
@Nullable public @Nullable java.lang.String getSelection()
public boolean isEditable()
@Environment(value=CLIENT)
protected void renderTextField(net.minecraft.client.util.math.MatrixStack matrices,
int x,
int y)
public WTextField setTextPredicate(java.util.function.Predicate<java.lang.String> predicate_1)
public WTextField setChangedListener(java.util.function.Consumer<java.lang.String> listener)
public WTextField setMaxLength(int max)
public WTextField setEnabledColor(int col)
public WTextField setDisabledColor(int col)
public WTextField setEditable(boolean editable)
@Nullable public @Nullable net.minecraft.text.Text getSuggestion()
public WTextField setSuggestion(@Nullable @Nullable java.lang.String suggestion)
public WTextField setSuggestion(@Nullable @Nullable net.minecraft.text.Text suggestion)
@Environment(value=CLIENT) public WTextField setBackgroundPainter(BackgroundPainter painter)
public boolean canFocus()
WWidgetpublic void onFocusGained()
WWidgetonFocusGained in class WWidget@Environment(value=CLIENT)
public void paint(net.minecraft.client.util.math.MatrixStack matrices,
int x,
int y,
int mouseX,
int mouseY)
WWidget@Environment(value=CLIENT) public InputResult onClick(int x, int y, int button)
WWidgetonClick in class WWidgetx - The X coordinate of the event, in widget-space (0 is the left edge of this widget)y - The Y coordinate of the event, in widget-space (0 is the top edge of this widget)button - The mouse button that was used. Button numbering is consistent with LWJGL Mouse (0=left, 1=right, 2=mousewheel click)InputResult.PROCESSED if the event is handled, InputResult.IGNORED otherwise.@Environment(value=CLIENT) public void onCharTyped(char ch)
WWidgetonCharTyped in class WWidgetch - the character typedpublic void insertText(int ofs,
java.lang.String s)
@Environment(value=CLIENT)
public void onKeyPressed(int ch,
int key,
int modifiers)
WWidgetonKeyPressed in class WWidgetkey - the GLFW scancode of the key@Environment(value=CLIENT)
public static int getCaretPos(java.lang.String s,
int x)
s - x - @Environment(value=CLIENT)
public static int getCaretOffset(java.lang.String s,
int pos)
s - pos -