Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where Container instances without children would not receive mouse events. #731

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/easeljs/display/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,8 @@ this.createjs = this.createjs||{};
**/
p._getObjectsUnderPoint = function(x, y, arr, mouse, activeListener, currentDepth) {
currentDepth = currentDepth || 0;
if (!currentDepth && !this._testMask(this, x, y)) { return null; }
var hitMask = this._testMask(this, x, y);
if (!currentDepth && !hitMask) { return null; }
var mtx, ctx = createjs.DisplayObject._hitTestContext;
activeListener = activeListener || (mouse&&this._hasMouseEventListener());

Expand Down Expand Up @@ -626,6 +627,11 @@ this.createjs = this.createjs||{};
else { return (mouse && !this.mouseChildren) ? this : child; }
}
}

if (hitMask && this.mouseEnabled) {
if (arr) { arr.push(this); }
return this;
}
return null;
};

Expand All @@ -638,11 +644,11 @@ this.createjs = this.createjs||{};
* @protected
**/
p._testMask = function(target, x, y) {
var mask = target.mask;
var mask = target.mask || target;
if (!mask || !mask.graphics || mask.graphics.isEmpty()) { return true; }

var mtx = this._props.matrix, parent = target.parent;
mtx = parent ? parent.getConcatenatedMatrix(mtx) : mtx.identity();
var parent = target.parent;
var mtx = parent ? parent.getConcatenatedMatrix(this._props.matrix.clone()) : mtx.identity();
mtx = mask.getMatrix(mask._props.matrix).prependMatrix(mtx);

var ctx = createjs.DisplayObject._hitTestContext;
Expand Down