public class UITextField extends UIComponent<UITextField> implements IScrollable, IGuiText<UITextField>
| Modifier and Type | Class and Description |
|---|---|
class |
UITextField.CursorPosition
This class determines a position inside the text divides in lines.
|
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 |
bgColor
Background color of this
UITextField. |
protected int |
charOffset
Number of character offset out of this
UITextField when drawn. |
protected int |
cursorColor
Cursor color for this
UITextField. |
protected UITextField.CursorPosition |
cursorPosition
Current cursor position.
|
protected GuiShape |
cursorShape
Shape used to draw the cursor of this
UITextField. |
protected FontRenderOptions |
disabledFro
The
FontRenderOptions to use for this UITooltip when disabled. |
protected boolean |
editable
Whether this
UITextField is editable. |
protected MalisisFont |
font
The
MalisisFont to use for this UITooltip. |
protected FontRenderOptions |
fro
The
FontRenderOptions to use for this UITooltip. |
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 int |
selectColor
Selection color for this
UITextField. |
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 com.google.common.base.Predicate<java.lang.String> |
validator
Validator
|
| 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 str)
Adds text at current cursor position.
|
void |
buildLines()
Builds the lines for 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.
|
int |
getCursorColor()
Gets the cursor color.
|
UITextField.CursorPosition |
getCursorPosition()
Gets the current cursor position.
|
FontRenderOptions |
getDisabledFontRendererOptions()
Gets the
FontRenderOptions used when disabled. |
MalisisFont |
getFont()
Gets the
MalisisFont. |
FontRenderOptions |
getFontRenderOptions()
Gets the
FontRenderOptions. |
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()
Gets the offset x.
|
float |
getOffsetY()
Gets the offset y.
|
java.lang.String |
getPropertyString()
Gets the property string.
|
UISlimScrollbar |
getScrollbar()
Gets the
UISlimScrollbar of this UITextField. |
float |
getScrollStep()
Gets the scroll step.
|
int |
getSelectColor()
Gets the select color.
|
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. |
com.google.common.base.Predicate<java.lang.String> |
getValidator()
Gets the predicate used to validate input text.
|
int |
getVerticalPadding()
Gets the vertical padding.
|
int |
getVisibleLines()
Gets the number of visible lines inside this
UITextField. |
protected boolean |
handleCtrlKeyDown(int keyCode)
Handles the key typed while a control key is pressed.
|
boolean |
isEditable()
Checks if is editable.
|
void |
onAddedToScreen()
Called when this
UIComponent is added to screen. |
boolean |
onButtonPress(int x,
int y,
MouseButton button)
On button press.
|
boolean |
onButtonRelease(int x,
int y,
MouseButton button)
On button release.
|
protected void |
onCursorUpdated()
Called when a cursor is updated.
|
boolean |
onDoubleClick(int x,
int y,
MouseButton button)
On double click.
|
boolean |
onDrag(int lastX,
int lastY,
int x,
int y,
MouseButton button)
On drag.
|
boolean |
onKeyTyped(char keyChar,
int keyCode)
On key typed.
|
void |
selectWord()
Select word.
|
void |
selectWord(int position)
Select word.
|
UITextField |
setAutoSelectOnFocus(boolean auto)
Sets whether this
UITextField should automatically select its text when focused. |
UITextField |
setCursorColor(int cursorColor)
Sets the cursor color.
|
void |
setCursorPosition(int x,
int y)
Sets the position of the cursor at the specified cooridnates.
|
UITextField |
setDisabledFontRendererOptions(FontRenderOptions fro)
Sets the
FontRenderOptions to use when disabled. |
UITextField |
setEditable(boolean editable)
Sets the editable.
|
void |
setFocused(boolean focused)
Sets the focused.
|
UITextField |
setFont(MalisisFont font)
Sets the
MalisisFont. |
UITextField |
setFontRenderOptions(FontRenderOptions fro)
Sets the
FontRenderOptions. |
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 |
setOptions(int bgColor,
int cursorColor,
int selectColor)
Sets the options.
|
void |
setParent(UIComponent<?> parent)
Sets the parent of this
UIComponent. |
UITextField |
setSelectColor(int selectColor)
Sets the select color.
|
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 |
setValidator(com.google.common.base.Predicate<java.lang.String> validator)
Sets the predicate used to validate input text.
|
protected void |
startSelecting()
Starts selecting text if Shift key is pressed.
|
protected boolean |
validateText(java.lang.String text)
Checks against if text is valid.
|
addControlComponent, attachData, componentX, componentY, draw, fireEvent, getAlpha, getAnchor, getComponentAt, getData, getGui, getHeight, getIconProvider, getName, getParent, getRawHeight, getRawWidth, getRenderer, getTooltip, getWidth, getX, getY, getZIndex, isDisabled, isFocused, isHovered, isInsideBounds, isRelativeHeight, isRelativeWidth, isVisible, onClick, onMouseMove, onRightClick, onScrollWheel, parentX, parentY, register, relativeX, relativeY, removeAllControlComponents, removeControlComponent, screenX, screenY, self, setAlpha, setAnchor, setDisabled, setHovered, setName, setPosition, setPosition, setTooltip, setTooltip, setVisible, setZIndex, toString, unregisterprotected MalisisFont font
MalisisFont to use for this UITooltip.protected FontRenderOptions fro
FontRenderOptions to use for this UITooltip.protected FontRenderOptions disabledFro
FontRenderOptions to use for this UITooltip when disabled.protected java.lang.StringBuilder text
UITextField.protected java.util.List<java.lang.String> lines
multiLine is true.protected boolean multiLine
UITextField handles multiline text.protected com.google.common.base.Predicate<java.lang.String> validator
protected int charOffset
UITextField when drawn.protected int lineOffset
UITextField when drawn. Always 0 if multiLine is falseprotected int lineSpacing
protected boolean selectingText
protected UITextField.CursorPosition cursorPosition
protected UITextField.CursorPosition selectionPosition
protected long startTimer
protected boolean autoSelectOnFocus
UITextField should auto select the text when gaining focus.protected boolean editable
UITextField is editable.protected UISlimScrollbar scrollBar
protected int bgColor
UITextField.protected int cursorColor
UITextField.protected int selectColor
UITextField.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 linepublic void setParent(UIComponent<?> parent)
UIComponentUIComponent.setParent in class UIComponent<UITextField>parent - the parentpublic void onAddedToScreen()
UIComponentUIComponent is added to screen.SpaceChangeEvent.SizeChangeEvent if this component size is relative.onAddedToScreen in class UIComponent<UITextField>public MalisisFont getFont()
IGuiTextMalisisFont.getFont in interface IGuiText<UITextField>public UITextField setFont(MalisisFont font)
IGuiTextMalisisFont.setFont in interface IGuiText<UITextField>font - the new fontpublic FontRenderOptions getFontRenderOptions()
IGuiTextFontRenderOptions.getFontRenderOptions in interface IGuiText<UITextField>public UITextField setFontRenderOptions(FontRenderOptions fro)
IGuiTextFontRenderOptions.setFontRenderOptions in interface IGuiText<UITextField>fro - the fropublic FontRenderOptions getDisabledFontRendererOptions()
FontRenderOptions used when disabled.public UITextField setDisabledFontRendererOptions(FontRenderOptions fro)
FontRenderOptions to use when disabled.fro - the froUITextFieldpublic java.lang.String getText()
UITextField.public void setText(java.lang.String text)
UITextField and place the cursor at the end.text - the new textpublic java.lang.String getSelectedText()
public int getCursorColor()
public UITextField setCursorColor(int cursorColor)
cursorColor - the cursor colorpublic int getSelectColor()
public UITextField setSelectColor(int selectColor)
selectColor - the select colorpublic UITextField setOptions(int bgColor, int cursorColor, int selectColor)
bgColor - the bg colorcursorColor - the cursor colorselectColor - the select colorpublic 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 int getLineSpacing()
public UITextField setLineSpacing(int lineSpacing)
UITextField.lineSpacing - the lineSpacing to setUITextFieldpublic void setLineOffset(int line)
line - the new line offsetpublic UITextField.CursorPosition getCursorPosition()
public UITextField.CursorPosition getSelectionPosition()
public void setCursorPosition(int x,
int y)
x - the x coordinatey - the y coordinatepublic UITextField setAutoSelectOnFocus(boolean auto)
UITextField should automatically select its text when focused.auto - the autoUITextFieldpublic boolean isEditable()
public UITextField setEditable(boolean editable)
editable - the editablepublic UISlimScrollbar getScrollbar()
UISlimScrollbar of this UITextField.public com.google.common.base.Predicate<java.lang.String> getValidator()
public UITextField setValidator(com.google.common.base.Predicate<java.lang.String> validator)
validator - the validatorpublic 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 IScrollablepublic int getVisibleLines()
UITextField.public int getLineHeight()
UITextField.public void buildLines()
UITextField.protected boolean validateText(java.lang.String text)
text - the textpublic void addText(java.lang.String str)
str - the textpublic 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 void selectWord()
public void selectWord(int position)
position - the positionprotected void onCursorUpdated()
protected void startSelecting()
public boolean onButtonPress(int x,
int y,
MouseButton button)
onButtonPress in class UIComponent<UITextField>x - the xy - the ybutton - the buttonpublic boolean onButtonRelease(int x,
int y,
MouseButton button)
onButtonRelease in class UIComponent<UITextField>x - the xy - the ybutton - the buttonpublic boolean onDrag(int lastX,
int lastY,
int x,
int y,
MouseButton button)
onDrag in class UIComponent<UITextField>lastX - the last xlastY - the last yx - the xy - the ybutton - the buttonpublic boolean onDoubleClick(int x,
int y,
MouseButton button)
onDoubleClick in class UIComponent<UITextField>x - the xy - the ybutton - the buttonpublic boolean onKeyTyped(char keyChar,
int keyCode)
onKeyTyped in interface IKeyListeneronKeyTyped in class UIComponent<UITextField>keyChar - the key charkeyCode - the key codeprotected boolean handleCtrlKeyDown(int keyCode)
keyCode - the key codepublic 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 java.lang.String getPropertyString()
getPropertyString in class UIComponent<UITextField>