Appearance
EditBox
A single-line text input built on InputBoxTemplate, with an optional label and an accept button ("OK"). Supports drag-and-drop of items, spells, macros, and chat-link insertion.
Create with AceGUI:Create("EditBox"). It inherits the Common Widget API.
Widget type: EditBox
Methods
SetText
method#
lua
widget:SetText(text?)Sets the contents of the edit box, resets the cursor to the start, and hides the accept button. Also updates the internally tracked "last text" so the change does not refire OnTextChanged.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
text (optional) | string | The string to display, or nil for empty. |
GetText
method#
lua
widget:GetText()Returns the current text in the edit box.
Returns
| Type | Description |
|---|---|
string | The current text in the edit box. |
SetLabel
method#
lua
widget:SetLabel(text?)Sets an optional label above the input. When a label is present the widget grows to height 44; when cleared it shrinks to height 26 and the input moves to the top.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
text (optional) | string | The label string, or nil/"" to hide the label. |
DisableButton
method#
lua
widget:DisableButton(disabled)Controls whether the inline "OK" accept button is shown when the text is edited. When disabled the button stays hidden.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
disabled | boolean | true to suppress the accept button. |
SetMaxLetters
method#
lua
widget:SetMaxLetters(num?)Sets the maximum number of characters the user can enter.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
num (optional) | number | Maximum letters; 0 (or nil) means no limit. |
SetFocus
method#
lua
widget:SetFocus()Gives keyboard focus to the edit box. If the frame is not yet shown, focus is applied the next time it shows.
ClearFocus
method#
lua
widget:ClearFocus()Removes keyboard focus from the edit box and cancels any pending focus-on-show.
HighlightText
method#
lua
widget:HighlightText(from, to)Highlights a range of the text.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
from | number | Start position of the selection. | |
to | number | End position of the selection. |
SetDisabled
method#
lua
widget:SetDisabled(disabled)Enables or disables the input. A disabled box ignores the mouse, drops focus, and greys the text and label.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
disabled | boolean | true to disable, false to enable. |
Defaults
On acquire the widget resets to: width 200, not disabled, no label, empty text, accept button enabled, and no max-letter limit. On release it clears focus.
Callbacks
OnEnterPressed
callback#
lua
OnEnterPressed(text)Fired when the user presses Enter, clicks the accept ("OK") button, or drops an item/spell/macro onto the box. If your handler returns a truthy value, the change is treated as cancelled: the accept sound is not played and the accept button stays visible. Subscribe with widget:SetCallback.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
text | string | The current value (or the dragged-in name). |
OnTextChanged
callback#
lua
OnTextChanged(text)Fired whenever the text changes and differs from the previous value. Shows the accept button. Subscribe with widget:SetCallback.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
text | string | The new value. |
OnEnter
callback#
lua
OnEnter()Fired when the mouse enters the input. Subscribe with widget:SetCallback.
OnLeave
callback#
lua
OnLeave()Fired when the mouse leaves the input. Subscribe with widget:SetCallback.
Example
lua
local eb = AceGUI:Create("EditBox")
eb:SetLabel("Player name")
eb:SetMaxLetters(12)
eb:SetCallback("OnEnterPressed", function(widget, event, text)
db.name = text
print("Saved name:", text)
end)