Call protected func from Blizzard button - WoWInterface
Thread Tools Display Modes
12-27-11, 10:43 AM   #1
A Defias Bandit
Join Date: Dec 2011
Posts: 3
Call protected func from Blizzard button


how do I hook an OnClick event of a blizzard button, e.g. the "CharacterMicroButton", to additionally call a protected function (e.g. the "CancelShapeshiftForm" function) when the button is clicked? is this even possible?

thanks for any hints in advance.

ps.: I posted this here too.
  Reply With Quote
12-27-11, 12:18 PM   #2
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
  4. --  Position and steal portrait texture
  5. new:SetAllPoints(old);
  6. MicroButtonPortrait:SetParent(new);
  7. old:Hide();
  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);
  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
12-27-11, 03:00 PM   #3
A Defias Bandit
Join Date: Dec 2011
Posts: 3
Thank you very much.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Call protected func from Blizzard button

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