Thread Tools Display Modes
11-16-15, 01:19 PM   #1
mster50
A Murloc Raider
Join Date: Nov 2015
Posts: 5
SecureUnitButtonTemplate Dropdown taint question

Hello again!

I have another stumper that I'd like to ask a question about - while working on a generic unit frame addon last night, I completed all the requisite boiler plate concerning setting up unit frames for entities (players, party members, raid members, etc), but I ran into this issue I can't seem to find much information on, and that is SecureUnitButtonTemplate menuFunc dropdowns. I've been looking into WoW's secure API, and when setting up the appropriate drop-down menu for the unit, rough example:

Lua Code:
  1. local testFrame = CreateFrame("Button", "TestFrame001", UIParent, "SecureUnitButtonTemplate");
  2. testFrame:RegisterForClicks("AnyUp");
  3. SecureUnitButton_OnLoad(testFrame, "player", ( function()
  4.      ToggleDropDownMenu(1, nil, PlayerFrameDropDown, "cursor", 106, 27);
  5. end);

The result works as expected, and you get the player's drop-down menu, but actions like Set Focus and others on other unit's drop down menus created this way are tainted (I evaluated the taint log) and thus blocked from fulfilling their actions. I researched the issue for quite some time, and I could never really find out what I'm supposed to do to prevent taint here, but still utilize the built-in drop down menus? I've looked into secure functions, and the like, but I either don't understand what's required to "securely" utilize Blizzard's unit dropdown menus, or it's not possible and I'm barking up the wrong tree.

Does anyone know what I'm missing, or can anyone point me in the right direction? I'm not satisfied with leaving it as is, I want this to work correctly. I studied Grid, and SUF, and both utilize Ace, which I suspect is helping with this issue, but I'd like to understand how it's helping, and I'm not finding resources that explain this well. Just little bits here and there, nothing concrete.

I'd buy a beer for anyone who could help me figure this out.

Thank you!
  Reply With Quote
11-16-15, 04:00 PM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Since I couldn't find any simple examples I could point to, I went ahead and wrote one.

The issue is that you can't call any blizzard function without tainting everything it does, so you have to do everything yourself, to whatever extent the restricted environment allows.

Here's a list of attributes you can use with your action button.
Lua Code:
  1. local button = CreateFrame('Button', 'MySpecialButton', UIParent, 'SecureUnitButtonTemplate')
  2.  
  3. button:SetNormalTexture('interface/icons/inv_mushroom_11')
  4. button:SetSize(64, 64)
  5. button:SetPoint('CENTER')
  6.  
  7. button:RegisterForClicks('AnyUp') -- only reacts to left clicks by default
  8. button:SetAttribute('unit', 'player') -- sets the associated unit to player
  9. button:SetAttribute('*type1', 'target') -- makes left click target the unit
  10. button:SetAttribute('*type2', 'togglemenu') -- makes right click toggle a unit menu
  Reply With Quote
11-16-15, 04:23 PM   #3
mster50
A Murloc Raider
Join Date: Nov 2015
Posts: 5
Thank you very much, semlar!

If you live in Utah, I'll seriously buy you a beer. I stayed up way too late last night researching this to no avail. And it's a one-line fix. Oi.

Last edited by mster50 : 11-16-15 at 05:13 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » SecureUnitButtonTemplate Dropdown taint question


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