Commit 29783cac authored by wjf's avatar wjf

l

parent f987a9a6
......@@ -381,10 +381,9 @@ export default class Container extends DisplayObject {
* 重写父类方法
*/
hitTestPoint(globalPoint: Point, isMouseEvent: boolean = false) {
//如果不可见
if (!this.visible) return null
//如果禁止子级的鼠标事件
// if (isMouseEvent && !this.mouseEnabled) return null;
//禁止子级的事件
if (isMouseEvent && !this.mouseChildren) return null;
var children = this.children;
var length = children.length
......
......@@ -334,23 +334,6 @@ export default class Sprite extends Container {
* @param isMouseEvent
*/
hitTestPoint(globalPoint: Point, isMouseEvent: boolean = false) {
/*if (!this.visible) return null
//如果禁止子级的鼠标事件
if (isMouseEvent && !this.mouseEnabled) return null;
//如果以后加缓存成位图,另写
let hitDisplayObject;
//先检查子级,因为子级层级更高
hitDisplayObject = super.hitTestPoint(globalPoint, isMouseEvent);
//子级已有,返回
if (hitDisplayObject) return hitDisplayObject;
//检查自己
hitDisplayObject = this.displayObjectHitTestPoint(globalPoint, isMouseEvent);
if (hitDisplayObject) return hitDisplayObject;
return null;*/
//不可见,返回
if (!this.visible) return null
if (isMouseEvent && !this.mouseEnabled && !this.mouseChildren) return null;
let hitDisplayObject;
//先检查子级,因为子级层级更高
hitDisplayObject = super.hitTestPoint(globalPoint, isMouseEvent);
......
......@@ -683,7 +683,7 @@ export class Stage extends Container {
if (eLen > 0) {
//有事件开始遍历显示列表
//找出最底层的显示对象
let d: any = s.hitTestPoint(cp, true);
let d: DisplayObject = s.hitTestPoint(cp, true);
// console.log(d)
let displayList: Array<DisplayObject> = [];
if (d) {
......@@ -705,7 +705,8 @@ export class Stage extends Container {
d = displayList[i];
for (let j = 0; j < eLen; j++) {
if (!events[j]["_bpd"]) {
if (d.hasEventListener(events[j].type)) {
//有事件,且mouseEnabled为true
if (d.hasEventListener(events[j].type) && d.mouseEnabled) {
events[j].currentTarget = d;
events[j].target = displayList[0];
lp = d.globalToLocal(cp, DisplayObject._bp);
......@@ -722,7 +723,8 @@ export class Stage extends Container {
d = displayList[i];
for (let j = 0; j < eLen; j++) {
if (!events[j]["_bpd"]) {
if (d.hasEventListener(events[j].type)) {
//有事件,且mouseEnabled为true
if (d.hasEventListener(events[j].type) && d.mouseEnabled) {
events[j].currentTarget = d;
events[j].target = displayList[eLen - 1];
lp = d.globalToLocal(cp, DisplayObject._bp);
......
......@@ -1130,35 +1130,13 @@ export default class Graphics extends Container {
* @param {Point} point - the point to test
*/
hitTestPoint(point: Point, isMouseEvent: boolean = false): DisplayObject {
/*let s = this;
if (!s.visible) return null;
if (isMouseEvent && !s.mouseEnabled) return null;
let hitDisplayObject;
//先检查子级,因为子级层级更高
hitDisplayObject = super.hitTestPoint(point, isMouseEvent);
//子级已有,返回
if (hitDisplayObject) return hitDisplayObject
//再粗略检查自己,先计算自身盒子
this.updateLocalBoundsSelf();
hitDisplayObject = this.displayObjectHitTestPoint(point, isMouseEvent);
//如果
if (hitDisplayObject) {
//不需要像素级检测直接返回
if (!s.hitTestByPixel) return hitDisplayObject;
//精确检测
return this.hitTestPointAccuratly(point)
}
return null*/
//不可见,返回
if (!this.visible) return null
if (isMouseEvent && !this.mouseEnabled && !this.mouseChildren) return null;
let hitDisplayObject;
//先检查子级,因为子级层级更高
hitDisplayObject = super.hitTestPoint(point, isMouseEvent);
//子级已有,返回
if (hitDisplayObject) return hitDisplayObject;
//子级没有的话,为了可以不updateLocalBoundsSelf,判断一下
if (isMouseEvent && !this.mouseEnabled) return null;
//再粗略检查自己,先计算自身盒子
this.updateLocalBoundsSelf();
hitDisplayObject = this.displayObjectHitTestPoint(point, isMouseEvent);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment