Thread: 2.7 Update
View Single Post
02/14/17, 09:43 AM   #109
Sounomi
Join Date: Oct 2014
Posts: 40
To assist with the need for a secure PostHook function and the continued lack of an official one, I figured out a bit of a hack to pull it off.

Code:
function SecurePostHook(object, funcName, hookFunc)
	local function Hook(...)
		local args = {...}
		zo_callLater(function() hookFunc(unpack(args)) end, 10)
	end
	
	ZO_PreHook(object, funcName, Hook)
end
This uses the existing ZO_PreHook function and injects a zo_callLater to call the code you want to be executed after the hooked function 10 ms later. From my testing, just about any function you'd want to hook into would be done by that point and its still short enough of a time that the user won't notice. I've tested it fairly extensively with a personal add-on of mine that hooks into the inventory lists with it and haven't run into any problems with it thus far.
  Reply With Quote