WoW:UIOBJECT EditBox: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(HasFocus wasnt here)
m (Move page script moved page UIOBJECT EditBox to UIOBJECT EditBox without leaving a redirect)
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{widget}}


For summary of ''all'' EditBox properties / methods see [[UISUMMARY EditBox]]
== Edit Box ==
A user can input text into the edit box which can then be retrieved using the [[API EditBox GetText|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 ==
See [[XML/EditBox]].
== LUA API ==
{{User:Watchout/Inheritance|
* [[UIOBJECT UIObject|UIObject]]
** [[UIOBJECT FontInstance|FontInstance]]
** [[UIOBJECT Region|Region]]
*** [[UIOBJECT Frame|Frame]]}}
=== Methods ===
* [[API EditBox AddHistoryLine|EditBox:AddHistoryLine("text")]] - Add text to the edit history.
* [[API EditBox ClearFocus|EditBox:ClearFocus()]] - Removes text input focus from this editbox element.
* [[API EditBox GetAltArrowKeyMode|EditBox:GetAltArrowKeyMode()]] - Returns value of '''ignoreArrows''' attribute, in 1/nil format.
* [[API EditBox GetBlinkSpeed|EditBox:GetBlinkSpeed()]] - Returns value of '''blinkSpeed''' attribute.
* [[API EditBox GetHistoryLines|EditBox:GetHistoryLines()]] - Get the number of history lines for this edit box
* [[API EditBox GetInputLanguage|EditBox:GetInputLanguage()]] - Get the input language (locale based not in-game)
* [[API EditBox GetMaxBytes|EditBox:GetMaxBytes()]]
* [[API EditBox GetMaxLetters|EditBox:GetMaxLetters()]] - Returns value of '''letters''' attribute.
* [[API EditBox GetNumLetters|EditBox:GetNumLetters()]] - Gets the number of letters in the box.
* [[API EditBox GetNumber|EditBox:GetNumber()]] - Returns number entered in the editbox, or 0 if editbox text is not a number.
* [[API EditBox GetText|EditBox:GetText()]] - Get the current text contained in the edit box.
* [[API EditBox GetTextInsets|EditBox:GetTextInsets()]] - Returns list of left,right,top,bottom text insets.
* [[API EditBox HasFocus|EditBox:HasFocus()]] - Returns true if the edit box has the focus.
* [[API EditBox HighlightText|EditBox:HighlightText(&#91;startPos,endPos&#93;)]] - Set the highlight to all or some of the edit box text.
* [[API EditBox Insert|EditBox:Insert("text")]] - Insert text into the edit box.
* [[API EditBox IsAutoFocus|EditBox:IsAutoFocus()]] - Returns value of '''autoFocus''' attribute, in 1/nil format.
* [[API EditBox IsMultiLine|EditBox:IsMultiLine()]] - Returns value of '''multiLine''' attribute, in 1/nil format.
* [[API EditBox IsNumeric|EditBox:IsNumeric()]] - Returns value of '''numeric''' attribute, in 1/nil format.
* [[API EditBox IsPassword|EditBox:IsPassword()]] - Returns value of '''password''' attribute, in 1/nil format.
* [[API EditBox SetAltArrowKeyMode|EditBox:SetAltArrowKeyMode()]]
* [[API EditBox SetAutoFocus|EditBox:SetAutoFocus()]]
* [[API EditBox SetBlinkSpeed|EditBox:SetBlinkSpeed()]]
* [[API EditBox SetFocus|EditBox:SetFocus()]]
* [[API EditBox SetHistoryLines|EditBox:SetHistoryLines()]] - Set the number of history lines to remember.
* [[API EditBox SetMaxBytes|EditBox:SetMaxBytes(maxBytes)]] - Set the maximum byte size for entered text.
* [[API EditBox SetMaxLetters|EditBox:SetMaxLetters(maxLetters)]] - Set the maximum number of letters for entered text.
* [[API EditBox SetMultiLine|EditBox:SetMultiLine()]]
* [[API EditBox SetNumber|EditBox:SetNumber(number)]]
* [[API EditBox SetNumeric|EditBox:SetNumeric()]]
* [[API EditBox SetPassword|EditBox:SetPassword()]]
* [[API EditBox SetSpacing|EditBox:SetSpacing()]] - Sets the spacing, between multiple lines
* [[API EditBox SetText|EditBox:SetText("text")]] - Set the text contained in the edit box.
* [[API EditBox SetTextInsets|EditBox:SetTextInsets(l,r,t,b)]]
* [[API EditBox ToggleInputLanguage|EditBox:ToggleInputLanguage()]]
=== Event Handlers ===
* [[UIHANDLER OnCursorChanged|OnCursorChanged]]
* [[UIHANDLER OnEditFocusGained|OnEditFocusGained]]
* [[UIHANDLER OnEditFocusLost|OnEditFocusLost]]
* [[UIHANDLER OnEnterPressed|OnEnterPressed]]
* [[UIHANDLER OnEscapePressed|OnEscapePressed]]
* [[UIHANDLER OnInputLanguageChanged|OnInputLanguageChanged]]
* [[UIHANDLER OnSpacePressed|OnSpacePressed]]
* [[UIHANDLER OnTabPressed|OnTabPressed]]
* [[UIHANDLER OnTextChanged|OnTextChanged]]
* [[UIHANDLER OnTextSet|OnTextSet]]
== On multi-line and EditBox:SetHeight() ==
Note that multi-line EditBoxes will ignore any attempts to set its height via [[API Region SetHeight|: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 [[API Region SetPoint|:SetPoint]]() will however size it like expected.

Latest revision as of 04:49, 15 August 2023

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]

User:Watchout/Inheritance

Methods[edit]


Event Handlers[edit]


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.