MCPcopy Create free account
hub / github.com/esengine/esengine / hitTestInChildren

Method hitTestInChildren

packages/fairygui/src/core/GRoot.ts:436–452  ·  view source on GitHub ↗
(container: GComponent, stageX: number, stageY: number)

Source from the content-addressed store, hash-verified

434 }
435
436 private hitTestInChildren(container: GComponent, stageX: number, stageY: number): GObject | null {
437 const count = container.numChildren;
438 for (let i = count - 1; i >= 0; i--) {
439 const child = container.getChildAt(i);
440 if (!child.visible || !child.touchable) continue;
441
442 const local = child.globalToLocal(stageX, stageY);
443 if (local.x >= 0 && local.x < child.width && local.y >= 0 && local.y < child.height) {
444 if (child instanceof GComponent) {
445 const deeper = this.hitTestInChildren(child, stageX, stageY);
446 if (deeper) return deeper;
447 }
448 return child;
449 }
450 }
451 return null;
452 }
453
454 public onMouseDown(data: IInputEventData): void {
455 this._touchTarget = this.hitTest(data.stageX, data.stageY);

Callers 1

hitTestMethod · 0.95

Calls 2

getChildAtMethod · 0.80
globalToLocalMethod · 0.80

Tested by

no test coverage detected