UIOBJECT EditBox
From WoWWiki
For summary of EditBox properties/methods see UISUMMARY EditBox
Contents |
Edit Box
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
| Inheritance |
|---|
|
Attributes
Attributes for <EditBox> element. Shown in parentheses are (attribute type; default value).
- font (string) - name of one of the predefined fonts to use in your EditBox. For example, "GameFontNormal".
- letters (int; 0) - maximum number of letters which can be entered in this EditBox. Zero means no character limit.
- blinkSpeed (float; 0.5) - speed of cursor blinking, interval in seconds between "blinks".
- numeric (boolean; false) - if true, then only digits 0-9 can be entered in this EditBox
- password (boolean; false) - if true, then asterisks will be displayed instead of whatever text you enter.
- multiLine (boolean; false) - multi-line EditBox
- historyLines (int; 0) - Number of lines to keep as a "history" for this editbox. You can cycle through editbox' history with arrows Up and Down (or Alt+Up, Alt+Down if attribute ignoreArrows set to true)
- autoFocus (boolean; true) - if true, then this EditBox will automatically receive keyboard focus when it is displayed.
- ignoreArrows (boolean; false) - if false, then pressing arrows on keyboard will move cursor around the EditBox. If set to true, then EditBox will ignore arrows and they will instead turn around your character in game world. In this case you can still move text cursor around your editbox with Alt-arrows.
Elements
LUA API
| Inheritance |
|---|
Methods
- 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: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: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
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.
