View Single Post
04-25-12, 10:48 PM   #1
Fox536
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Apr 2012
Posts: 31
SecureState Driver issue

Hi, does anyone know why a secure state driver wouldn't work for Forms (Shapeshifted forms).
Im inheriting from the templates SecureActionButtonTemplate, SecureHandlerDragTemplate, and SecureUnitButtonTemplate.

this is some of the code I've tried
Lua Code:
  1. self:SetAttribute("_onstate-form", [[
  2.  if newstate == "form" then
  3.   print("form");
  4.  elseif newstate == "noform" then
  5.   print("no form!");
  6.  else
  7.   print("error!");
  8.  end
  9. ]]);
  10. RegisterStateDriver(self, "form", "[@player, noform] noform; [@player, form] form");

Any help would be great.

[Edit] it appears that the state driver only fails to work when using it on a button widget. I Don't know why it will not work, any clues would be great.


[Edit]Apparently the only way to get this to work correctly with buttons, is to use this...
Lua Code:
  1. self = CreateFrame("Button", name, nil, "SecureActionButtonTemplate, SecureHandlerDragTemplate, SecureHandlerStateTemplate");
  2. SecureHandlerWrapScript(self, "OnAttributeChanged", self, [[
  3.     if (name == "state-form") then
  4.         if (value == "noform") then
  5.             self:SetAttribute("actionpage", GetActionBarPage());
  6.         elseif (value == 1) then
  7.             self:SetAttribute("actionpage", 6 + GetBonusBarOffset());
  8.         elseif (value == 3) then
  9.             self:SetAttribute("actionpage", 6 + GetBonusBarOffset());
  10.         else
  11.             self:SetAttribute("actionpage", GetActionBarPage());
  12.         end
  13.     end
  14. ]]);
  15. RegisterStateDriver(self, "form", "[form:0] noform; [form:0] noform; [form:1] 1; [form:3] 3; noform");

Anyways though I found the answer after digging through Google and about 12 hours of work lol, i only wish there was more documentation on Secure Wow Api and it's many quirks lol

Last edited by Fox536 : 04-26-12 at 09:57 PM.
  Reply With Quote