diff --git a/libs/actions.js b/libs/actions.js index f40ed879..90e9a5e5 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -94,7 +94,7 @@ actions.prototype.doRegisteredAction = function (action) { var actions = this.actions[action]; if (!actions) return false; for (var i = 0; i < actions.length; ++i) { - if (core.doFunc.apply(this, [actions[i].func].concat(Array.prototype.slice.call(arguments, 1)))) + if (core.doFunc.apply(core, [actions[i].func, this].concat(Array.prototype.slice.call(arguments, 1)))) return true; } return false; diff --git a/libs/control.js b/libs/control.js index 1181a098..fe2cedae 100644 --- a/libs/control.js +++ b/libs/control.js @@ -69,7 +69,7 @@ control.prototype._setRequestAnimationFrame = function () { if (b.func) { try { if (core.isPlaying() || !b.needPlaying) - core.doFunc(b.func, timestamp); + core.doFunc(b.func, core.control, timestamp); } catch (e) { main.log(e); @@ -1257,7 +1257,7 @@ control.prototype.unregisterReplayAction = function (name) { control.prototype._doReplayAction = function (action) { for (var i in this.replayActions) { try { - if (core.doFunc(this.replayActions[i].func, action)) return true; + if (core.doFunc(this.replayActions[i].func, this, action)) return true; } catch (e) { main.log(e); main.log("ERROR in replayActions["+this.replayActions[i].name+"]:已自动注销该项。"); @@ -2393,7 +2393,7 @@ control.prototype.unregisterResize = function (name) { control.prototype._doResize = function (obj) { for (var i in this.resizes) { try { - if (core.doFunc(this.resizes[i].func, obj)) return true; + if (core.doFunc(this.resizes[i].func, this, obj)) return true; } catch (e) { main.log(e); main.log("ERROR in resizes["+this.resizes[i].name+"]:已自动注销该项。"); diff --git a/libs/core.js b/libs/core.js index fd88bdd7..2b56dcfe 100644 --- a/libs/core.js +++ b/libs/core.js @@ -383,9 +383,12 @@ core.prototype._forwardFunc = function (name, funcname) { eval("core." + funcname + " = function (" + parameters + ") {\n\treturn core." + name + "." + funcname + "(" + parameters + ");\n}"); } -core.prototype.doFunc = function (func) { - if (typeof func == 'string') func = core.plugin[func]; - return func.apply(this, Array.prototype.slice.call(arguments, 1)); +core.prototype.doFunc = function (func, _this) { + if (typeof func == 'string') { + func = core.plugin[func]; + _this = core.plugin; + } + return func.apply(_this, Array.prototype.slice.call(arguments, 2)); } /** diff --git a/libs/events.js b/libs/events.js index 22f4de0a..7afbc881 100644 --- a/libs/events.js +++ b/libs/events.js @@ -247,7 +247,7 @@ events.prototype.unregisterSystemEvent = function (type) { events.prototype.doSystemEvent = function (type, data, callback) { if (this.systemEvents[type]) { try { - return core.doFunc(this.systemEvents[type], data, data, callback); + return core.doFunc(this.systemEvents[type], this, data, data, callback); } catch (e) { main.log(e); @@ -722,7 +722,7 @@ events.prototype.doEvent = function (data, x, y, prefix) { var type = data.type; if (this.actions[type]) { try { - return core.doFunc(this.actions[type], data, x, y, prefix); + return core.doFunc(this.actions[type], this, data, x, y, prefix); } catch (e) { main.log(e);