Skip to content

MultiLineEditBox

A scrollable, multi-line text input with an optional label and an "Accept" button. Supports inserting chat links and dragging spells/items into the box.

Create with AceGUI:Create("MultiLineEditBox"). It inherits the Common Widget API.

Widget type: MultiLineEditBox

Methods

SetText

method#
lua
widget:SetText(text?)

Sets the contents of the edit box. Setting text programmatically clears the highlight, resets the cursor, and disables the Accept button.

Parameters

ParameterTypeDefaultDescription
text (optional)stringThe text to place in the box.

GetText

method#
lua
widget:GetText()

Returns the current contents of the edit box.

Returns

TypeDescription
stringThe current contents of the edit box.

SetLabel

method#
lua
widget:SetLabel(text?)

Sets the label shown above the box. A non-empty label is shown (reserving 10px of header height); an empty/nil label is hidden. Triggers a re-layout.

Parameters

ParameterTypeDefaultDescription
text (optional)stringThe label text, or ""/nil to hide it.

SetNumLines

method#
lua
widget:SetNumLines(value?)

Sets the visible height of the box in lines (minimum 4). Triggers a re-layout.

Parameters

ParameterTypeDefaultDescription
value (optional)number4Number of visible lines; values below 4 are clamped to 4.

SetMaxLetters

method#
lua
widget:SetMaxLetters(num?)

Limits the number of characters the box accepts.

Parameters

ParameterTypeDefaultDescription
num (optional)number0Maximum character count; 0 (the default) means no limit.

DisableButton

method#
lua
widget:DisableButton(disabled)

Shows or hides the Accept button. Triggers a re-layout (the box is taller when the button is hidden).

Parameters

ParameterTypeDefaultDescription
disabledbooleantrue hides the button, false shows it.

SetFocus

method#
lua
widget:SetFocus()

Gives keyboard focus to the edit box. If the frame is not yet shown, focus is applied on its next OnShow.

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 characters in the edit box.

Parameters

ParameterTypeDefaultDescription
fromnumberStart character index.
tonumberEnd character index.

GetCursorPosition

method#
lua
widget:GetCursorPosition()

Returns the current cursor position in the edit box.

Returns

TypeDescription
numberThe current cursor position in the edit box.

SetCursorPosition

method#
lua
widget:SetCursorPosition(...)

Sets the cursor position in the edit box.

Parameters

ParameterTypeDefaultDescription
...numberArguments forwarded to the edit box's SetCursorPosition (the cursor index).

SetDisabled

method#
lua
widget:SetDisabled(disabled)

Enables or disables the editbox. When disabled it drops focus, ignores the mouse, greys the text and label, and disables the accept button.

Parameters

ParameterTypeDefaultDescription
disabledbooleantrue to disable, false to enable.

Defaults

On acquire the widget resets to: empty text, not disabled, width 200, Accept button shown, 4 visible lines, not " entered", and no character limit. On release it clears focus.

Callbacks

OnEnterPressed

callback#
lua
OnEnterPressed(text)

Fired when the Accept button is clicked (focus is cleared first). If no handler returns a truthy value, the Accept button is disabled afterward. Subscribe with widget:SetCallback.

Parameters

ParameterTypeDefaultDescription
textstringThe full box contents.

OnTextChanged

callback#
lua
OnTextChanged(text)

Fired on user input (not programmatic SetText); also enables the Accept button. Subscribe with widget:SetCallback.

Parameters

ParameterTypeDefaultDescription
textstringThe current contents.

OnEditFocusGained

callback#
lua
OnEditFocusGained()

Fired when the edit box gains keyboard focus. Subscribe with widget:SetCallback.

OnEditFocusLost

callback#
lua
OnEditFocusLost()

Fired when the edit box loses keyboard focus. Subscribe with widget:SetCallback.

OnEnter

callback#
lua
OnEnter()

Fired when the mouse enters the edit box or scroll area (once, until it leaves). Subscribe with widget:SetCallback.

OnLeave

callback#
lua
OnLeave()

Fired when the mouse leaves the edit box or scroll area. Subscribe with widget:SetCallback.

Example

lua
local edit = AceGUI:Create("MultiLineEditBox")
edit:SetLabel("Notes")
edit:SetNumLines(8)
edit:SetText("Type your notes here...")
edit:SetCallback("OnEnterPressed", function(widget, event, text)
    print("Saved:", text)
end)

Ace3, a World of Warcraft addon framework.