API Frame HookScript

Post hooks a script handler (secure).

frame:HookScript("handler", function)

Arguments

 * ("handler", func)


 * handler : String - The handler to attach func to (OnShow, OnEvent, et al)
 * func : Function - The function to call. Unlike SetScript, nil throws an error. func is called with arguments (frame, arg1, arg2, ...) (event being arg1 for OnEvent handlers)

Example
for i = 1, 4 do    local frame = _G["PartyMemberFrame"..i]     frame:HookScript("OnClick", function(self, button)         print(self:GetName .. " clicked with " .. button)    end) end

Result
Alert the player when he clicks a party member's portrait while preserving the security of the unit frame after calling its original handler.