Widget script handlers

From Wowpedia
Jump to: navigation, search
For a full list that is not condensed by inheritance, see Widget script handlers/Complete list.

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. Script types are defined in the XML Schema Definition.

Widget API

ScriptObject:GetScript(scriptType [, bindingType]) - Returns the widget's script handler.
ScriptObject:SetScript(scriptType, handler) - Sets the widget's script handler.
ScriptObject:HookScript(scriptType, handler [, bindingType]) - Securely hooks a script handler.
ScriptObject:HasScript(scriptType) - Returns whether the widget supports a script type.

Widget hierarchy

Base Frame Animation
 
  • PlayerModel


  • ModelScene
  • ModelSceneActor
  • MovieFrame
  • OffScreenFrame
  • POIFrame
  • ArchaeologyDigSiteFrame
  • QuestPOIFrame
  • ScenarioPOIFrame
  • Alpha
  • Scale
  • LineScale
  • Translation
  • LineTranslation
  • Path
  • Rotation
  • TextureCoordTranslation

Example

Registers for clicks on a Button widget with the OnMouseDown script.

local btn = CreateFrame("Button", nil, UIParent, "UIPanelButtonTemplate")
btn:SetPoint("CENTER")
btn:SetSize(100, 40)
btn:SetText("Click me")
btn:HookScript("OnMouseDown", function(self, button)
	print("You clicked me with "..button)
end)
-- You clicked me with LeftButton

ScriptObject

ScriptObject is an abstract widget type that provides support for widget scripts.

OnLoad(self) - Run when the frame is created.
OnUpdate(self, elapsed) - Run each time the screen is drawn by the game engine.

AnimationGroup

AnimationGroup has the handlers from ScriptObject, plus the following:

OnFinished(self, requested) - Run when the animation (or animation group) finishes animating.
OnLoop(self, loopState) - Run when the animation group's loop state changes.
OnPause(self) - Run when the animation (or animation group) is paused.
OnPlay(self) - Run when the animation (or animation group) begins to play.
OnStop(self, requested) - Run when the animation (or animation group) is stopped.

Animation

Animation has the handlers from ScriptObject, plus the following:

OnFinished(self, requested)
OnPause(self)
OnPlay(self)
OnStop(self, requested)

Frame

Frame (inherits from Region and ScriptObject) provides the basis for interaction with the user, and registering and responding to game events.

OnAttributeChanged(self, key, value) - Run when a frame attribute is changed.
OnChar(self, text) - Run for each text character typed in the frame.
OnDisable(self) - Run when the frame is disabled.
OnDragStart(self, button) - Run when the mouse is dragged starting in the frame.
OnDragStop(self) - Run when the mouse button is released after a drag started in the frame,
OnEnable(self) - Run when the frame is enabled.
OnEnter(self, motion) - Run when the mouse cursor enters the frame's interactive area.
OnEvent(self, event, ...) - Run whenever an event fires for which the frame is registered.
OnHide(self) - Run when the frame's visbility changes to hidden.
OnHyperlinkClick(self, link, text, button) - Run when the mouse clicks a hyperlink on the FontInstance object.
OnHyperlinkEnter(self, link, text) - Run when the mouse moves over a hyperlink on the FontInstance object.
OnHyperlinkLeave(self, link, text) - Run when the mouse moves away from a hyperlink on the FontInstance object.
OnKeyDown(self, key) - Run when a keyboard key is pressed if the frame is keyboard enabled.
OnKeyUp(self, key) - Run when a keyboard key is released if the frame is keyboard enabled.
OnLeave(self, motion) - Run when the mouse cursor leaves the frame's interactive area.
OnMouseDown(self, button) - Run when a mouse button is pressed while the cursor is over the frame.
OnMouseUp(self, button) - Run when the mouse button is released following a mouse down action in the frame.
OnMouseWheel(self, delta) - Run when the frame receives a mouse wheel scrolling action.
OnReceiveDrag(self) - Run when the mouse button is released after dragging into the frame.
OnShow(self) - Run when the frame becomes visible.
OnSizeChanged(self, width, height) - Run when a frame's size changes.

Browser

OnButtonUpdate(self, action)
OnEditFocusGained(self)
OnEditFocusLost(self)
OnError(self, msg)
OnEscapePressed(self)
OnExternalLink(self, url)

Button

Button (inherits from Frame) responds to mouse clicks.

OnClick(self, button, down) - Run when the button is clicked.
OnDoubleClick(self, button) - Run when the button is double-clicked.
PostClick(self, button, down) - Run immediately following the button's `OnClick` handler with the same arguments.
PreClick(self, button, down) - Run immediately before the button's `OnClick` handler with the same arguments.

Checkout

OnButtonUpdate(self, action)
OnEditFocusGained(self)
OnEditFocusLost(self)
OnError(self, msg)
OnEscapePressed(self)
OnExternalLink(self, url)
OnRequestNewSize(self, width, height)

ColorSelect

OnColorSelect(self, r, g, b) - Run when the color select frame's color selection changes.

Cooldown

Cooldowns provide an animated translucent 'sweep' that rotates along a timer.

Cooldown has all the handlers from Frame, plus the following:

OnCooldownDone(self) - Completion of the cooldown (sweep) animation

EditBox

OnArrowPressed(self, key)
OnCharComposition(self, text) - Run when the edit box's input composition mode changes.
OnCursorChanged(self, x, y, width, height) - Run when the position of the text insertion cursor in the edit box changes.
OnEditFocusGained(self) - Run when the edit box becomes focused for keyboard input.
OnEditFocusLost(self) - Run when the edit box loses keyboard input focus.
OnEnterPressed(self) - Run when the Enter (or Return) key is pressed while the edit box has keyboard focus.
OnEscapePressed(self) - Run when the Escape key is pressed while the edit box has keyboard focus.
OnInputLanguageChanged(self, language) - Run when the edit box's language input mode changes.
OnSpacePressed(self) - Run when the space bar is pressed while the edit box has keyboard focus.
OnTabPressed(self) - Run when the Tab key is pressed while the edit box has keyboard focus.
OnTextChanged(self, userInput) - Run when the edit box's text is changed.
OnTextSet(self) - Run when the edit box's text is set 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

OnHorizontalScroll(self, offset) - Run when the scroll frame's horizontal scroll position changes.
OnScrollRangeChanged(self, xrange, yrange) - Run when the scroll frame's scroll position is changed.
OnVerticalScroll(self, offset) - Run when the scroll frame's 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) - 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.

References