Hello all,
I have some trouble working out how the new secure stuff should be handled... This code worked fine untill patch 2.0...
I first add a menu command to the UnitFrame menu's:
Code:
table.insert(UnitPopupMenus["PLAYER"], 8, "MYMOD");
table.insert(UnitPopupMenus["FRIEND"], 4, "MYMOD");
Then I hook the UnitPopup function:
Code:
MyOrig_UnitPopup_OnClick = UnitPopup_OnClick;
UnitPopup_OnClick = My_UnitPopup_OnClick;
The function My_UnitPopup_OnClick consists of some text output to the default chatframe:
Code:
local dropdownFrame = getglobal(UIDROPDOWNMENU_INIT_MENU);
local val = this.value;
local unit = dropdownFrame.unit;
local name = dropdownFrame.name;
if (val == "MYMOD") then
-- Retrieve some info, output some text.
end
The above hooking works fine as long it concerns safe functions, but gives the famous "... has been blocked from an action ..."-error as soon as one tries to select eg. duel, or dismiss pet.
Ok so, this needs to be done secure. No problem, so I changed the hooking code to:
Code:
hooksecurefunc("UnitPopup_OnClick", My_UnitPopup_OnClick);
Interesting but true: Nothing changed... I still get the same error. I am puzzled as I really do not execute any "harmfull code" when an option is selected that isn't mine.
Would love to see your expert options on this!
Greetings!
Anea