Package net.risingworld.api.ui
Class UITextField
java.lang.Object
net.risingworld.api.ui.UIElement
net.risingworld.api.ui.UITextField
Represents a text field, i.e an element where the player can enter text.
- 
Field SummaryFields inherited from class net.risingworld.api.ui.UIElementhoverStyle, style
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a new, empty text field.UITextField(String initialText) Creates a new text field and sets an initial text.
- 
Method SummaryModifier and TypeMethodDescriptionvoidgetCurrentText(Player player, Callback<String> callback) Gets the current text of the textfield.charintGets the max number of allowed characters in this text field.booleanisMasked()Gets whether or not masking is currently enabled, i.e if all characters should be replaced by a mask character automatically.booleanbooleanGets whether or not the text field is in read-only mode.voidsetFontColor(float r, float g, float b, float a) Sets a font color for the text field.voidsetFontColor(int rgba) Sets a font color for the label.voidsetFontSize(float size) Sets the font size for the text field.voidsetMasked(boolean set) If set to true, individual characters entered into the text field will be masked.voidsetMaskedCharacter(char c) If the text field is masked (seesetMasked(boolean)), this determines the character that should replace the original characters.voidsetMaxCharacters(int length) Sets the max number of allowed characters in this text field.voidsetMultiLine(boolean set) Determines if the text field should support multi-line input, i.e if the player should be able to enter multiple lines of text.voidsetReadOnly(boolean set) If set to true, the player will no longer be able to change the text of the text field.voidSets the text of the text field.Methods inherited from class net.risingworld.api.ui.UIElementaddChild, addStyleSheet, addToClassList, getChildCount, getChilds, getID, getParent, getPluginID, isClickable, onClick, removeAllChilds, removeChild, removeFromClassList, removeFromParent, removeStyleSheet, resetPivot, resetPosition, setBackgroundColor, setBackgroundColor, setBorder, setBorderColor, setBorderColor, setBorderEdgeRadius, setClickable, setOpacity, setPickable, setPivot, setPosition, setSize, setVisible, updateStyle
- 
Constructor Details- 
UITextFieldpublic UITextField()Creates a new, empty text field.
- 
UITextFieldCreates a new text field and sets an initial text.- Parameters:
- initialText- the initial text you want to set for this text field.
 
 
- 
- 
Method Details- 
setTextSets the text of the text field.- Parameters:
- text- the new text you want to set.
 
- 
setMultiLinepublic void setMultiLine(boolean set) Determines if the text field should support multi-line input, i.e if the player should be able to enter multiple lines of text. Disabled by default.- Parameters:
- set- true to enable multi-line, false to disable it (single-lined text field)
 
- 
isMultiLinepublic boolean isMultiLine()
- 
setReadOnlypublic void setReadOnly(boolean set) If set to true, the player will no longer be able to change the text of the text field.- Parameters:
- set- true to set the text field to read-only, false to allow the player to enter text.
 
- 
isReadOnlypublic boolean isReadOnly()Gets whether or not the text field is in read-only mode.- Returns:
- true if the text field is read-only (i.e the player cannot modify it), false if not (default).
 
- 
setMaskedpublic void setMasked(boolean set) If set to true, individual characters entered into the text field will be masked. Useful for password fields, for example. Disabled by default.- Parameters:
- set- true to replace all characters in the text field with a masked character (e.g '*'), false to disable this behaviour.
- See Also:
 
- 
isMaskedpublic boolean isMasked()Gets whether or not masking is currently enabled, i.e if all characters should be replaced by a mask character automatically.- Returns:
- true if masking is enabled, false if not.
 
- 
setMaskedCharacterpublic void setMaskedCharacter(char c) If the text field is masked (seesetMasked(boolean)), this determines the character that should replace the original characters. By default the masked character is '*'- Parameters:
- c- the new mask character you want to set for the text field (only relevant if text field is masked).
 
- 
getMaskedCharacterpublic char getMaskedCharacter()
- 
setMaxCharacterspublic void setMaxCharacters(int length) Sets the max number of allowed characters in this text field. Set to -1 for no limit (default).- Parameters:
- length- the max length of the text (number of characters) that could be entered into the text field.
 
- 
getMaxCharacterspublic int getMaxCharacters()Gets the max number of allowed characters in this text field.- Returns:
- the number of allowed characters, or -1 if there is no limit.
 
- 
setFontSizepublic void setFontSize(float size) Sets the font size for the text field. Please note that Unity currently only supports pixel values for text fields.
 Note: This is just a helper method. Internally it only changes the style fontSize value!- Parameters:
- size- the font size in pixels.
 
- 
setFontColorpublic void setFontColor(float r, float g, float b, float a) Sets a font color for the text field.
 Note: This is just a helper method. Internally it changes the style color property!- Parameters:
- r- the new red component for the font color (0-1).
- g- the new green component for the font color (0-1).
- b- the new blue component for the font color (0-1).
- a- the new alpha component (opacity) for the font color (0-1).
 
- 
setFontColorpublic void setFontColor(int rgba) Sets a font color for the label.
 Note: This is just a helper method. Internally it changes the style color property!- Parameters:
- rgba- an int RGBA value describing the new color (e.g 0xFF0000FF for fully opaque red etc).
 
- 
getCurrentTextGets the current text of the textfield. Since the text will be received from the client, you have to work with callbacks: The callback gets invoked once the server has queried the text field from the client.- Parameters:
- player- the player you want to get the text from.
- callback- the callback which will be called once the text has been received from the client.
- Example: Get text from textfield using lambda expression
 
 
-