The API is no longer being updated here until further notice. |
- These templates are defined in
FrameXML/SecureHandlerTemplates.xml
andFrameXML/SecureHandlers.lua
- These templates are defined in
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[]
- SecureHandlerBaseTemplate:Execute(body) - Executes a code snippet in the restricted environment.
- SecureHandlerBaseTemplate:WrapScript(header, script, preBody [, postBody]) - Wraps a widget script with code snippets executed in the restricted environment.
- SecureHandlerBaseTemplate:UnwrapScript(frame, script) - Strips (and returns) the outermost-wrapped handler.
- SecureHandlerBaseTemplate:SetFrameRef(id, refFrame) - Creates a frame reference accessible in the restricted environment.
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[]
- Iriel's Field Guide to Secure Handlers 4.0 revision 1
|