Skip to content
everloot

Lore archive · Warcraft Wiki, 2023 dump

SecureHandlerAttributeTemplate

Last wiki revision 2009-06-03

SecureHandlerAttributeTemplate is one of the SecureHandler templates introduced in Patch 3.0. Those templates exist in order to allow addon code to execute within a restricted environment, where it may perform protected actions but has access only to a limited subset of the API. SecureHandlerAttributeTemplate executes snippets whenever an attribute on the frame (whose name does not begin with "_") changes value.

The handler executes the following snippets in a restricted environment:

  • _onattributechanged (self, name, value) : The snippet is executed when the an attribute changes value; unless its name begins with an underscore.
  • self : Secure frame handle to the frame.
  • name : String - attribute name.
  • value : Mixed - new attribute value. Note that if the value is not a string, boolean or a number, it'll be replaced with nil -- this a limitation enforced by the restricted environment.

Suppose we wanted to respond to :SetFrameRef invocations on the frame by handling the frame in some fashion. local frame = CreateFrame("FRAME", "MyAttributeFrame", UIParent, "SecureHandlerAttributeTemplate"); frame:SetAttribute("_onattributechanged", [=[ if name:match("frameref%-.+") then -- value is nil, since the original type is userdata. -- We can fix that by asking for the frame ref: value = self:GetFrameRef(name:match("frameref%-(.+)")); -- Now handle the name/value pair in some fashion... print("SetFrameRef: ", name, value); end ]=]); frame:SetFrameRef("ref", frame);

Source

https://warcraft.wiki.gg/wiki/SecureHandlerAttributeTemplate · retrieved 2023-11-13 · CC BY-SA 4.0

Converted from wikitext with templates, tables and images removed, so some sentences may be missing values.

This archive predates WoW: Forever. For collected gameplay facts see the Forever database. Search the archive.