mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 15:52:40 +08:00
Merge pull request #389 from pandamicro/master
修复 mouse out 事件被上层节点阻断问题
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user