Widget: EditBox
← Widget API < EditBox
For summary of all EditBox properties / methods see UISUMMARY EditBox
Edit Box[edit]
A user can input text into the edit box which can then be retrieved using the EditBox:GetText() function.
When declaring an edit box object make sure that you either set "font" attribute for <EditBox> element, or include a <FontString> element, thus declaring which font is to be used to display text input into your edit box. If you do not do so EditBox will not display any text, just a blinking cursor.
<EditBox name="TestEditBox"> .. Size .. Anchors .. Layers .. etc. <FontString inherits="GameFontNormal"/> </EditBox>
XML[edit]
See XML/EditBox.
LUA API[edit]
Methods[edit]
- EditBox:AddHistoryLine("text") - Add text to the edit history.
- EditBox:ClearFocus() - Removes text input focus from this editbox element.
- EditBox:GetAltArrowKeyMode() - Returns value of ignoreArrows attribute, in 1/nil format.
- EditBox:GetBlinkSpeed() - Returns value of blinkSpeed attribute.
- 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() - Returns value of letters attribute.
- EditBox:GetNumLetters() - Gets the number of letters in the box.
- EditBox:GetNumber() - Returns number entered in the editbox, or 0 if editbox text is not a number.
- EditBox:GetText() - Get the current text contained in the edit box.
- EditBox:GetTextInsets() - Returns list of left,right,top,bottom text insets.
- EditBox:HasFocus() - Returns true if the edit box has the focus.
- 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() - Returns value of autoFocus attribute, in 1/nil format.
- EditBox:IsMultiLine() - Returns value of multiLine attribute, in 1/nil format.
- EditBox:IsNumeric() - Returns value of numeric attribute, in 1/nil format.
- EditBox:IsPassword() - Returns value of password attribute, in 1/nil format.
- 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:SetSpacing() - Sets the spacing, between multiple lines
- EditBox:SetText("text") - Set the text contained in the edit box.
- EditBox:SetTextInsets(l,r,t,b)
- EditBox:ToggleInputLanguage()
Event Handlers[edit]
- OnCursorChanged
- OnEditFocusGained
- OnEditFocusLost
- OnEnterPressed
- OnEscapePressed
- OnInputLanguageChanged
- OnSpacePressed
- OnTabPressed
- OnTextChanged
- OnTextSet
On multi-line and EditBox:SetHeight()[edit]
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.