Main Menu |
---|
|
The API is no longer being updated here until further notice. |
Widget scripts allow you to respond to user interaction and other types of widget events (such as a frame being shown or hidden). This page lists the available scripts and the list of widget types for which each script is valid.
Example[]
Registers for clicks on a Button widget with the OnClick script.
local btn = CreateFrame("Button", nil, UIParent, "UIPanelButtonTemplate")
btn:SetPoint("CENTER")
btn:SetSize(100, 40)
btn:SetText("Click me")
btn:SetScript("OnClick", function(self, button, down)
print("Pressed", button, down and "down" or "up")
end)
btn:RegisterForClicks("AnyDown", "AnyUp")
-- Pressed LeftButton down
-- Pressed LeftButton up
Object[]
- OnLoad(self) - Invoked when the object is created.
- OnUpdate(self, elapsed) - Invoked on every frame.
AnimationGroup[]
- OnFinished(self, requested) - Invoked when the animation group finishes animating.
- OnLoop(self, loopState) - Invoked when the animation group's loop state changes.
- OnPause(self) - Invoked when the animation group is paused.
- OnPlay(self) - Invoked when the animation group begins to play.
- OnStop(self, requested) - Invoked when the animation group is stopped.
Animation[]
- OnFinished(self, requested) - Invoked when the animation finishes animating.
- OnPause(self) - Invoked when the animation is paused.
- OnPlay(self) - Invoked when the animation begins to play.
- OnStop(self, requested) - Invoked when the animation is stopped.
ScriptRegion[]
- OnEnter(self, motion) - Invoked when the mouse cursor enters the frame's interactive area.
- OnHide(self) - Invoked when the frame's visbility changes to hidden.
- OnLeave(self, motion) - Invoked when the mouse cursor leaves the frame's interactive area.
- OnMouseDown(self, button) - Invoked when a mouse button is pressed while the cursor is over the frame.
- OnMouseUp(self, button) - Invoked when the mouse button is released following a mouse down action in the frame.
- OnMouseWheel(self, delta) - Invoked when the frame receives a mouse wheel scrolling action.
- OnShow(self) - Invoked when the frame becomes visible.
Frame[]
- OnAttributeChanged(self, key, value) - Invoked when a secure frame attribute is changed.
- OnChar(self, text) - Invoked for each text character typed in the frame.
- OnDisable(self) - Invoked when the frame is disabled.
- OnDragStart(self, button) - Invoked when the mouse is dragged starting in the frame
- OnDragStop(self) - Invoked when the mouse button is released after a drag started in the frame,
- OnEnable(self) - Invoked when the frame is enabled.
- OnEvent(self, event, ...) - Invoked whenever an event fires for which the frame is registered.
- OnGamePadButtonDown(self, button) - Invoked when a gamepad button is pressed.
- OnGamePadButtonUp(self, button) - Invoked when a gamepad button is released.
- OnGamePadStick(self, stick, x, y, len) - Invoked when a gamepad stick is moved.
- OnHyperlinkClick(self, link, text, button, region, left, bottom, width, height) - Invoked when the mouse clicks a hyperlink on the FontInstance object.
- OnHyperlinkEnter(self, link, text, region, left, bottom, width, height) - Invoked when the mouse moves over a hyperlink on the FontInstance object.
- OnHyperlinkLeave(self) - Invoked when the mouse moves away from a hyperlink on the FontInstance object.
- OnKeyDown(self, key) - Invoked when a keyboard key is pressed if the frame is keyboard enabled.
- OnKeyUp(self, key) - Invoked when a keyboard key is released if the frame is keyboard enabled.
- OnReceiveDrag(self) - Invoked when the mouse button is released after dragging into the frame.
- OnSizeChanged(self, width, height) - Invoked when a frame's size changes.
Button[]
- OnClick(self, self, button, down) - Invoked when clicking a button.
- OnDoubleClick(self, self, button) - Invoked when double-clicking a button.
- PostClick(self, button, down) - Invoked immediately after `OnClick`.
- PreClick(self, button, down) - Invoked immediately before `OnClick`.
ColorSelect[]
- OnColorSelect(self, r, g, b) - Invoked when the ColorSelect frame's color selection changes.
Cooldown[]
Cooldown (inherits from Frame) displays "clock-like" sweep and leading-edge effects over abilities and buffs.
- OnCooldownDone(self) - Run when a cooldown has finished.
EditBox[]
EditBox (inherits from Frame and FontInstance) is an interactive text field for keyboard input.
- OnArrowPressed(self, key)
- OnCharComposition(self, text) - Run when changing the input composition mode.
- OnCursorChanged(self, x, y, w, h) - Run when moving the text insertion cursor.
- OnEditFocusGained(self) - Run when gaining edit focus.
- OnEditFocusLost(self) - Run when losing edit focus.
- OnEnterPressed(self) - Run when pressing Enter while the widget has focus.
- OnEscapePressed(self) - Run when pressing Escape while the widget has focus.
- OnSpacePressed(self) - Run when pressing Space while the widget has focus.
- OnInputLanguageChanged(self, language) - Run when changing the language input mode.
- OnTabPressed(self) - Run when pressing Tab while the widget has focus.
- OnTextChanged(self, userInput) - Run when changing the value.
- OnTextSet(self) - Run when setting the value programmatically
FogOfWarFrame[]
- OnUiMapChanged(self, uiMapID)
GameTooltip[]
- OnTooltipAddMoney(self, cost, maxcost) - Run when an amount of money should be added to the tooltip.
- OnTooltipCleared(self) - Run when the tooltip is hidden or its content is cleared.
- OnTooltipSetAchievement(self) - Run when the tooltip is filled with information about an achievement.
- OnTooltipSetDefaultAnchor(self) - Run when the tooltip is repositioned to its default anchor location.
- OnTooltipSetEquipmentSet(self) - Run when the tooltip is filled with information about an equipment set.
- OnTooltipSetFramestack(self, highlightFrame) - Run when the tooltip is filled with a list of frames under the mouse cursor.
- OnTooltipSetItem(self) - Run when the tooltip is filled with information about an item.
- OnTooltipSetQuest(self) - Run when the tooltip is filled with information about a quest.
- OnTooltipSetSpell(self) - Run when the tooltip is filled with information about a spell.
- OnTooltipSetUnit(self) - Run when the tooltip is filled with information about a unit.
Model[]
PlayerModel / TabardModel inherit the handlers from Model.
- OnAnimFinished(self) - Run when the model's animation finishes.
- OnAnimStarted(self)
- OnModelLoaded(self)
CinematicModel[]
- OnPanFinished
DressUpModel[]
- OnDressModel(self)
MovieFrame[]
- OnMovieFinished(self) - Run when a movie frame's movie ends.
- OnMovieHideSubtitle(self) - Runs when the movie's most recently displayed subtitle should be hidden.
- OnMovieShowSubtitle(self, text) - Runs when a subtitle for the playing movie should be displayed.
ScrollFrame[]
ScrollFrame (inherits from Frame) may be customized to vertically or horizontally scroll other widgets.
- OnHorizontalScroll(self, offset) - Run when the horizontal scroll position changes.
- OnScrollRangeChanged(self, xrange, yrange) - Run when the scroll position changes.
- OnVerticalScroll(self, offset) - Run when the vertical scroll position changes.
Slider[]
- OnMinMaxChanged(self, min, max) - Run when the slider's or status bar's minimum and maximum values change.
- OnValueChanged(self, value, userInput) - Run when the slider's or status bar's value changes.
StatusBar[]
- OnMinMaxChanged(self, min, max) - Run when the slider's or status bar's minimum and maximum values change.
- OnValueChanged(self, value) - Run when the slider's or status bar's value changes.
ModelScene[]
- OnDressModel(self)
ModelSceneActor[]
Scripts for this widget can only be set from XML.
- OnAnimFinished(self)
- OnModelLoaded(self)
- OnModelLoading
References[]
- James Whitehead II 2010-02-05. World of Warcraft Programming: A Guide and Reference for Creating WoW Addons - 2nd Edition.
- wowprogramming 2017-09-03. Widget script handlers listing.
- Townlong Yak 2017-06-27. WidgetAPI.lua.
- Resike 2019-05-21. WidgetReference.lua.