WoWInterface (
-   Lua/XML Help (
-   -   Call protected func from Blizzard button (

Crudor 12-27-11 10:43 AM

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.

SDPhantom 12-27-11 12:18 PM

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

Crudor 12-27-11 03:00 PM

Thank you very much.

All times are GMT -6. The time now is 02:16 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI