User:Watchout/DevWidget
Edit Box
A user can input text into the edit box which can then be retrieved using the EditBox:GetText() function.
When you declare an edit box object make sure that you include a FontString element which defines the Font which is used to display the text inputted into the EditBox. Otherwise EditBox will not display any text or being able to receive text input from the user, instead it would just display a portion of the blinking cursor (when focused)
<EditBox name="TestEditBox"> .. Size .. Anchors .. Layers .. ecc. <FontString inherits="GameFontNormal"/> </EditBox>
On multi-line and EditBox:SetHeight()
Note that multi-line EditBoxes will ignore any attempts to set its height via :SetHeight() or via Dimension attributes in XML. They will start out the height of a single line of text, and keep expanding their area as needed. This effect becomes visible if the editbox has a backdrop set, or a texture anchored to its corners.
Explicitly setting the top and bottom anchors with :SetPoint() will however size it like expected, but the text will still expand below the borders. (The effect will be similar to html elements positioned absolutely with width/height restricted)
XML
Attributes
- letters (int; default=0)
- blinkSpeed (float; default=0.5)
- numeric (boolean; default=false)
- password (boolean; default=false)
- multiline (boolean; default=false)
- historyLines (int; default=0)
- autoFocus (boolean; default=true)
- ignoreArrows (boolean; default=false)
Elements
- SampleElementName (SampleElementType)
- SampleElementNameIsType
- FontString (UIOBJECTTYPE FontStringType)
- HighlightColor (UIOBJECTTYPE ColorType)
- TextInsets (UIOBJECTTYPE Inset)
LUA API
Inheritance |
---|
Methods
- EditBox:AddHistoryLine("text") - Add text to the edit history.
- EditBox:ClearFocus()
- EditBox:GetAltArrowKeyMode
- EditBox:GetBlinkSpeed
- EditBox:GetHistoryLines() - Get the number of history lines for this edit box
- EditBox:GetInputLanguage() - Get the input language (locale based not in-game)
- EditBox:GetMaxBytes
- EditBox:GetMaxLetters
- EditBox:GetNumLetters() - Gets the number of letters in the box.
- EditBox:GetNumber()
- EditBox:GetText() - Get the current text contained in the edit box.
- EditBox:GetTextInsets
- EditBox:HighlightText([startPos,endPos]) - Set the highlight to all or some of the edit box text.
- EditBox:Insert("text") - Insert text into the edit box.
- EditBox:IsAutoFocus
- EditBox:IsMultiLine
- EditBox:IsNumeric
- EditBox:IsPassword
- EditBox:SetAltArrowKeyMode
- EditBox:SetAutoFocus
- EditBox:SetBlinkSpeed
- EditBox:SetFocus()
- EditBox:SetHistoryLines() - Set the number of history lines to remember.
- EditBox:SetMaxBytes(maxBytes) - Set the maximum byte size for entered text.
- EditBox:SetMaxLetters(maxLetters) - Set the maximum number of letters for entered text.
- EditBox:SetMultiLine
- EditBox:SetNumber(number)
- EditBox:SetNumeric
- EditBox:SetPassword
- EditBox:SetText("text") - Set the text contained in the edit box.
- EditBox:SetTextInsets(l,r,t,b)
- EditBox:ToggleInputLanguage()
Event Handlers
- OnCursorChanged
- OnEditFocusGained
- OnEditFocusLost
- OnEnterPressed
- OnEscapePressed
- OnInputLanguageChanged
- OnSpacePressed
- OnTabPressed
- OnTextChanged
- OnTextSet