Quantcast
WoWInterface - View Single Post - Call protected func from Blizzard button
View Single Post
12-27-11, 12:18 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,936
You'll need to replace the button with a SecureActionButton copy of it.
Notice CharacterMicroButton doesn't use an OnClick handler, but it should work all the same.

lua Code:
  1. local old,new=CharacterMicroButton,CreateFrame("Button","CharacterMicroButton","MainMenuBarArtFrame","SecureActionButton MainMenuBarMicroButton");
  2. CharacterMicroButton=new;-- CreateFrame() will only create the button with the name set and not overwrite the global
  3.  
  4. --  Position and steal portrait texture
  5. new:SetAllPoints(old);
  6. MicroButtonPortrait:SetParent(new);
  7. old:Hide();
  8.  
  9. --  Copy script handlers and apply OnLoad
  10. new:HookScript("OnMouseDown",old:GetScript("OnMouseDown"));
  11. new:HookScript("OnMouseUp",old:GetScript("OnMouseUp"));
  12. new:HookScript("OnEvent",CharacterMicroButton_OnEvent);
  13. CharacterMicroButton_OnLoad(new);
  14.  
  15. --  Now for the secure stuff
  16. new:SetAttribute("type","macro");--         Set to run a macro
  17. new:SetAttribute("macrotext",SLASH_CANCELFORM1);--  Make sure we use the localized slash command
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote