CEventPump.addHook Member
Adds an event hook to be called when matching events are processed.
Syntax
object.addHook(pattern, f, name, neg, enabled, hooks);
Arguments
Argument | Summary |
---|---|
pattern | |
f | The function to call when an event matches pattern. |
name | A unique name for the hook. Used for removing the hook and debugging. |
neg | Optional. If specified with a true value, the hook will be called for events not matching pattern. Otherwise, the hook will be called for events matching pattern. |
enabled | Optional. If specified, sets the initial enabled/disabled state of the hook. By default, hooks are enabled. See getHook. |
hooks | Internal. Do not use. |
Returns
Remarks
All hooks should be given a meaningful name, to aid removal and debugging. For plugins, an ideal technique for the name is to use plugin.id as a prefix (e.g. plugin.id + "-my-super-hook").
See Also
Source Code
function ep_addhook(pattern, f, name, neg, enabled, hooks)
{
if (typeof hooks == "undefined")
hooks = this.hooks;
if (typeof f != "function")
return false;
if (typeof enabled == "undefined")
enabled = true;
else
enabled = Boolean(enabled);
neg = Boolean(neg);
var hook = {
pattern: pattern,
f: f,
name: name,
neg: neg,
enabled: enabled
};
hooks.push(hook);
return hook;
}