public class UITextField extends UIComponent<UITextField> implements IScrollable
| Modifier and Type | Class and Description |
|---|---|
protected class |
UITextField.CursorPosition
The Class CursorPosition.
|
ITransformable.Alpha, ITransformable.Brightness, ITransformable.Color, ITransformable.Position<T>, ITransformable.Rotate, ITransformable.Scale, ITransformable.Size<T>, ITransformable.Translate| Modifier and Type | Field and Description |
|---|---|
protected boolean |
autoSelectOnFocus
Whether this
UITextField should auto select the text when gaining focus. |
protected int |
charOffset
Number of character offset out of this
UITextField when drawn. |
protected UITextField.CursorPosition |
cursorPosition
Current cursor position.
|
protected GuiShape |
cursorShape
Shape used to draw the cursor of this
UITextField. |
protected float |
fontScale
Font scale used to draw the text *.
|
protected GuiIcon |
iconTextfield
Icon used to draw this
UITextField. |
protected GuiIcon |
iconTextfieldDisabled
Icon used to draw this
UITextField when disabled. |
protected int |
lineOffset
Number of line offset out of this
UITextField when drawn. |
protected java.util.List<java.lang.String> |
lines
Different lines if
multiLine is true. |
protected int |
lineSpacing
Space used between each line.
|
protected boolean |
multiLine
Whether this
UITextField handles multiline text. |
protected UISlimScrollbar |
scrollBar
Scrollbar of the textfield
|
protected boolean |
selectingText
Whether currently selecting text.
|
protected UITextField.CursorPosition |
selectionPosition
Current selection cursor position.
|
protected GuiShape |
selectShape
Shape used to draw the selection box.
|
protected long |
startTimer
Cursor blink timer.
|
protected java.lang.StringBuilder |
text
Current text of this
UITextField. |
protected int |
textColor
Color of the text for this
UITextField. |
| Constructor and Description |
|---|
UITextField(MalisisGui gui,
boolean multiLine)
Instantiates a new empty
UITextField. |
UITextField(MalisisGui gui,
java.lang.String text)
Instantiates a new single lined
UITextField. |
UITextField(MalisisGui gui,
java.lang.String text,
boolean multiLine)
Instantiates a new
UITextField. |
| Modifier and Type | Method and Description |
|---|---|
void |
addText(java.lang.String text)
Adds text at current cursor position.
|
protected void |
buildLines()
Builds the lines for this
UITextField. |
protected void |
createShape(MalisisGui gui)
Creates the shapes used by this
UITextField. |
void |
deleteFromCursor(int amount)
Deletes the specified amount of characters.
|
void |
deleteSelectedText()
Deletes the text currently selected.
|
void |
deleteWord(boolean backwards)
Deletes the text from current cursor position to the next space.
|
void |
drawBackground(GuiRenderer renderer,
int mouseX,
int mouseY,
float partialTick)
Draws the background.
|
void |
drawCursor(GuiRenderer renderer)
Draws the cursor of this
UITextField. |
void |
drawForeground(GuiRenderer renderer,
int mouseX,
int mouseY,
float partialTick)
Draws the foreground.
|
void |
drawSelectionBox(GuiRenderer renderer)
Draw the selection box of this
UITextField. |
void |
drawText(GuiRenderer renderer)
Draws the text of this
UITextField. |
int |
getContentHeight()
Gets the content height.
|
int |
getContentWidth()
Gets the content width.
|
UITextField.CursorPosition |
getCursorPosition()
Gets the current cursor position.
|
float |
getFontScale()
Gets the font scale used by this
UITextField. |
int |
getHorizontalPadding()
Gets the horizontal padding.
|
int |
getLineHeight()
Gets the line height of this
UITextField. |
int |
getLineSpacing()
Gets the line spacing used when drawing.
|
float |
getOffsetX() |
float |
getOffsetY() |
java.lang.String |
getPropertyString()
Gets the property string.
|
UISlimScrollbar |
getScrollbar()
Gets the
UISlimScrollbar of this UITextField. |
float |
getScrollStep() |
java.lang.String |
getSelectedText()
Gets the currently selected text.
|
UITextField.CursorPosition |
getSelectionPosition()
Gets the selection position.
|
java.lang.String |
getText()
Gets the text of this
UITextField. |
int |
getTextColor()
Gets the text color.
|
int |
getVerticalPadding()
Gets the vertical padding.
|
protected boolean |
handleCtrlKeyDown(int keyCode)
Handles the key typed while a control key is pressed.
|
void |
keyTyped(KeyboardEvent event)
Called when a key is pressed.
|
void |
onCursorUpdated()
Called when a cursor is updated.
|
void |
onDoubleClick(MouseEvent.DoubleClick event)
Called when a mouse button is double clicked over this
UITextField. |
void |
onDrag(MouseEvent.Drag event)
Called when a mouse button is dragged over this
UITextField. |
void |
onMousePress(MouseEvent.Press event)
Called when a mouse button is pressed over this
UITextField. |
void |
onMouseRelease(MouseEvent.Release event)
Called when a mouse button is released over this
UITextField. |
UITextField |
setAutoSelectOnFocus(boolean auto)
Sets whether this
UITextField should automatically select its text when focused. |
void |
setCursorPosition(int x,
int y)
Sets the position of the cursor at the specified cooridnates.
|
void |
setFocused(boolean focused)
Sets the focused.
|
UITextField |
setFontScale(float fontScale)
Sets the font scale for this
UITextField. |
void |
setLineOffset(int line)
Sets the line offset.
|
UITextField |
setLineSpacing(int lineSpacing)
Sets the line spacing for this
UITextField. |
void |
setOffsetX(float offsetX,
int delta)
Sets the offset x.
|
void |
setOffsetY(float offsetY,
int delta)
Sets the offset y.
|
UITextField |
setSize(int width,
int height)
Sets the size of this
UITextField. |
void |
setText(java.lang.String text)
Sets the text of this
UITextField and place the cursor at the end. |
UITextField |
setTextColor(int color)
Sets the text color for this
UITextField. |
protected void |
startSelecting()
Starts selecting text if Shift key is pressed.
|
protected boolean |
validateText(java.lang.String text)
Checks against if text is valid.
|
protected int |
visibleLines()
Gets the number of visible lines inside this
UITextField. |
addControlComponent, componentX, componentY, draw, fireEvent, fireKeyboardEvent, fireMouseEvent, getAlpha, getAnchor, getComponentAt, getGui, getHeight, getName, getParent, getRawHeight, getRawWidth, getTooltip, getWidth, getX, getY, getZIndex, isDisabled, isFocused, isHovered, isInsideBounds, isRelativeHeight, isRelativeWidth, isVisible, onAddedToScreen, parentX, parentY, register, relativeX, relativeY, removeAllControlComponents, removeControlComponent, screenX, screenY, setAlpha, setAnchor, setDisabled, setHovered, setName, setParent, setPosition, setPosition, setTooltip, setTooltip, setVisible, setZIndex, toString, unregisterprotected java.lang.StringBuilder text
UITextField.protected java.util.List<java.lang.String> lines
multiLine is true.protected boolean multiLine
UITextField handles multiline text.protected UITextField.CursorPosition cursorPosition
protected UITextField.CursorPosition selectionPosition
protected boolean selectingText
protected int charOffset
UITextField when drawn.protected int lineOffset
UITextField when drawn. Always 0 if multiLine is falseprotected int lineSpacing
protected long startTimer
protected boolean autoSelectOnFocus
UITextField should auto select the text when gaining focus.protected int textColor
UITextField.protected UISlimScrollbar scrollBar
protected float fontScale
protected GuiShape cursorShape
UITextField.protected GuiShape selectShape
protected GuiIcon iconTextfield
UITextField.protected GuiIcon iconTextfieldDisabled
UITextField when disabled.public UITextField(MalisisGui gui, java.lang.String text, boolean multiLine)
UITextField.gui - the guitext - the textmultiLine - whether the textfield handles multiple linespublic UITextField(MalisisGui gui, java.lang.String text)
UITextField.gui - the guitext - the textpublic UITextField(MalisisGui gui, boolean multiLine)
UITextField.gui - the guimultiLine - the multi lineprotected void createShape(MalisisGui gui)
UITextField.gui - the guipublic java.lang.String getText()
UITextField.public void setText(java.lang.String text)
UITextField and place the cursor at the end.text - the new textpublic UITextField setSize(int width, int height)
setSize in interface ITransformable.Size<UITextField>setSize in class UIComponent<UITextField>width - the widthheight - the heightpublic void setFocused(boolean focused)
setFocused in class UIComponent<UITextField>focused - the new focusedpublic UITextField setFontScale(float fontScale)
UITextField.fontScale - the font scaleUITextFieldpublic float getFontScale()
UITextField.public int getLineSpacing()
public void setLineOffset(int line)
line - the new line offsetpublic UITextField setLineSpacing(int lineSpacing)
UITextField.lineSpacing - the lineSpacing to setUITextFieldpublic int getLineHeight()
UITextField.public UITextField.CursorPosition getCursorPosition()
public UITextField.CursorPosition getSelectionPosition()
public void setCursorPosition(int x,
int y)
x - the x coordinatey - the y coordinatepublic UITextField setTextColor(int color)
UITextField.color - the colorUITextFieldpublic int getTextColor()
UITextField.public UITextField setAutoSelectOnFocus(boolean auto)
UITextField should automatically select its text when focused.auto - the autoUITextFieldpublic UISlimScrollbar getScrollbar()
UISlimScrollbar of this UITextField.protected void buildLines()
public void addText(java.lang.String text)
text - the textprotected boolean validateText(java.lang.String text)
text - the textpublic java.lang.String getSelectedText()
public void deleteSelectedText()
public void deleteFromCursor(int amount)
amount - the amount of characters to deletepublic void deleteWord(boolean backwards)
backwards - whether to look left for the next spacepublic int getContentWidth()
getContentWidth in interface IScrollablepublic int getContentHeight()
getContentHeight in interface IScrollablepublic float getOffsetX()
getOffsetX in interface IScrollablepublic void setOffsetX(float offsetX,
int delta)
setOffsetX in interface IScrollableoffsetX - the offset xdelta - the deltapublic float getOffsetY()
getOffsetY in interface IScrollablepublic void setOffsetY(float offsetY,
int delta)
setOffsetY in interface IScrollableoffsetY - the offset ydelta - the deltapublic float getScrollStep()
getScrollStep in interface IScrollablepublic int getVerticalPadding()
getVerticalPadding in interface IScrollablepublic int getHorizontalPadding()
getHorizontalPadding in interface IScrollableprotected int visibleLines()
UITextField.public void onCursorUpdated()
public void drawBackground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick)
drawBackground in class UIComponent<UITextField>renderer - the renderermouseX - the mouse xmouseY - the mouse ypartialTick - the partial tickpublic void drawForeground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick)
drawForeground in class UIComponent<UITextField>renderer - the renderermouseX - the mouse xmouseY - the mouse ypartialTick - the partial tickpublic void drawText(GuiRenderer renderer)
UITextField.renderer - the rendererpublic void drawCursor(GuiRenderer renderer)
UITextField.renderer - the rendererpublic void drawSelectionBox(GuiRenderer renderer)
UITextField.renderer - the rendererpublic void onMousePress(MouseEvent.Press event)
UITextField.event - the eventpublic void onMouseRelease(MouseEvent.Release event)
UITextField.event - the eventpublic void onDrag(MouseEvent.Drag event)
UITextField.event - the eventpublic void onDoubleClick(MouseEvent.DoubleClick event)
UITextField.event - the eventprotected void startSelecting()
public void keyTyped(KeyboardEvent event)
event - the eventprotected boolean handleCtrlKeyDown(int keyCode)
keyCode - the key codepublic java.lang.String getPropertyString()
getPropertyString in class UIComponent<UITextField>