Thread Tools Display Modes
Prev Previous Post   Next Post Next
02-07-18, 05:12 AM   #1
Eungavi
A Theradrim Guardian
Join Date: Nov 2017
Posts: 64
SecureHandler template object fails visibility check

So, I'm currently trying to make a button that cancels aura on right mouse button and here's what I've got atm

Lua Code:
  1. local button = CreateFrame("Button", nil, UIParent, "SecureHandlerClickTemplate");
  2. button:RegisterEvent("PLAYER_ENTERING_WORLD");
  3. button:RegisterUnitEvent("UNIT_AURA", "player");
  4. button:RegisterForClicks("RightButtonUp");
  5. button:SetSize(50, 50);
  6. button:SetPoint("TOP", 0, -150);
  7. button:SetScript("OnEvent", function(self, event, ...)
  8.     if event == "PLAYER_ENTERING_WORLD" or event == "UNIT_AURA" then
  9.         if event == "PLAYER_ENTERING_WORLD" then
  10.             self:UnregisterEvent("PLAYER_ENTERING_WORLD");
  11.         end
  12.  
  13.         local spellName = GetSpellInfo(self.spellID);
  14.  
  15.         local _, _, _, count, _, duration, expires = UnitBuff("player", spellName);
  16.  
  17.         local cd = self.cd;
  18.         if duration and duration > 0 then
  19.             cd:SetCooldown(expires - duration, duration);
  20.             cd:Show();
  21.  
  22.             self.icon:SetDesaturated(false);
  23.  
  24.             self.duration = duration;
  25.         else
  26.             cd:Hide();
  27.  
  28.             self.icon:SetDesaturated(true);
  29.  
  30.             self.duration = nil;
  31.         end
  32.  
  33.         self.count:SetText((count and count > 1) and count or "");
  34.     end
  35. end);
  36. button:SetAttribute("_onclick", [=[
  37.     if button == "RightButton" and not down then
  38.         local name = self:GetAttribute("spellName");
  39.  
  40.         local cd = self:GetFrameRef("cd");
  41.        
  42.         if cd:IsShown() then
  43.             CancelUnitBuff("player", name);
  44.         end
  45.     end
  46. ]=]);
  47.  
  48. button.spellID = 241846;
  49. button:SetAttribute("spellName", GetSpellInfo(button.spellID));
  50.  
  51. local cd = CreateFrame("Cooldown", nil, button, "CooldownFrameTemplate");
  52. cd:SetAllPoints(button);
  53. cd:SetReverse(true);
  54. cd:SetDrawEdge(true);
  55. cd:SetHideCountdownNumbers(false);
  56.  
  57. button:SetFrameRef("cd", cd);

It currently fails at L#42 where I check cd's visibility.

Would that be because cd itself is not a SecureHandler template object?

Last edited by Eungavi : 02-07-18 at 07:32 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » SecureHandler template object fails visibility check

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off