Merge pull request #389 from pandamicro/master

修复 mouse out 事件被上层节点阻断问题
This commit is contained in:
pandamicro
2016-02-26 16:52:36 +08:00
2 changed files with 12 additions and 1 deletions
+10
View File
@@ -128,6 +128,8 @@ var _mouseEvents = [
EventType.MOUSE_WHEEL,
];
var currentHovered = null;
var _touchStartHandler = function (touch, event) {
var pos = touch.getLocation();
var node = this.owner;
@@ -179,6 +181,13 @@ var _mouseMoveHandler = function (event) {
if (node._hitTest(pos, this)) {
event.stopPropagation();
if (!this._previousIn) {
// Fix issue when hover node switched, previous hovered node won't get MOUSE_LEAVE notification
if (currentHovered) {
event.type = EventType.MOUSE_LEAVE;
currentHovered.owner.dispatchEvent(event);
currentHovered._previousIn = false;
}
currentHovered = this;
event.type = EventType.MOUSE_ENTER;
node.dispatchEvent(event);
this._previousIn = true;
@@ -190,6 +199,7 @@ var _mouseMoveHandler = function (event) {
event.type = EventType.MOUSE_LEAVE;
node.dispatchEvent(event);
this._previousIn = false;
currentHovered = null;
}
};
var _mouseUpHandler = function (event) {
+2 -1
View File
@@ -179,6 +179,7 @@ if (CC_TEST) {
* @param {any} [p5]
*/
CallbacksInvoker.prototype.invoke = function (key, p1, p2, p3, p4, p5) {
this._toRemove.length = 0;
this._invoking = key;
var list = this._callbackTable[key], i;
if (list) {
@@ -205,7 +206,7 @@ CallbacksInvoker.prototype.invoke = function (key, p1, p2, p3, p4, p5) {
// Delay removing
for (i = 0; i < this._toRemove.length; ++i) {
var toRemove = this._toRemove[i];
this.remove(this._invoking, toRemove[0], toRemove[1]);
this.remove(key, toRemove[0], toRemove[1]);
}
this._toRemove.length = 0;
if (this._toRemoveAll) {