Wowpedia
Advertisement
These templates are defined in FrameXML/SecureHandlerTemplates.xml and FrameXML/SecureHandlers.lua

SecureHandlers (created by inheriting SecureHandlerBaseTemplate) use code snippets inside the RestrictedEnvironment. Each snippet is a string that behaves like the body of a Lua function, but it can only contain a subset of the World of Warcraft API.

Defined methods

Details

  • The base template has an OnLoad widget script which adds the four defined methods.
  • Other templates (listed below) use Frame:SetAttribute() to run widget script handlers in the RestrictedEnvironment.
Template Description Attribute (arguments)
SecureHandlerBaseTemplate Enables common methods on the frame none
SecureHandlerStateTemplate Only "state-xxx" attribute changes _onstate-xxx(self, stateid, newstate)
SecureHandlerAttributeTemplate Any attribute change _onattributechanged(self, name, value)
SecureHandlerClickTemplate Clicks _onclick(self, button, down)
SecureHandlerDoubleClickTemplate Double clicks _ondoubleclick(self, button, down)
SecureHandlerDragTemplate Dragging _ondragstart(self, button), _onreceivedrag(self, button, kind, value, ...)
SecureHandlerMouseUpDownTemplate Mouse up/down _onmouseup(self, button), _onmousedown(self, button)
SecureHandlerMouseWheelTemplate Mouse wheel _onmousewheel(self, delta)
SecureHandlerEnterLeaveTemplate Mouse entering/leaving _onenter(self), _onleave(self)
SecureHandlerShowHideTemplate Frame shown/hidden _onshow(self), _onhide(self)

Example

local frame = CreateFrame("Frame", nil, "SecureHandlerClickTemplate")
frame:SetAttribute("_onclick", [=[
	-- self, button, down
	if button == "RightButton" then
		self:Hide();
	end
]=])

External links


Advertisement