I couldn’t find any so I just used modified _processPicking but I’d rather use something in the library. Is there any way to pick a control under an x,y?
import { Container, Control } from "@babylonjs/gui";
declare module '@babylonjs/gui' {
interface Container {
pickControl(x: number, y: number, callback: (control: Control) => void);
}
}
Container.prototype.pickControl = function(x: number, y: number, callback: (control: Control) => void) {
if (!this._isEnabled || !this.isVisible || this.notRenderable) {
return false;
}
// checks if the picking position is within the container
const contains = this.contains(x, y);
// if clipChildren is off, we should still pass picking events to children even if we don't contain the pointer
if (!contains && this.clipChildren) {
return false;
}
// Checking backwards to pick closest first
for (let index = this._children.length - 1; index >= 0; index--) {
const child = this._children[index];
if (child.pickControl(x, y, callback)) {
return true;
}
}
if (!contains) {
return false;
}
if (!this.isHitTestVisible) {
return false;
}
callback(this);
return true;
}
import { Control } from "@babylonjs/gui";
declare module '@babylonjs/gui' {
interface Control {
pickControl(x: number, y: number, callback: (control: Control) => void);
}
}
Control.prototype.pickControl = function(x: number, y: number, callback: (control: Control) => void) {
if (!this._isEnabled) {
return false;
}
if (!this.isHitTestVisible || !this.isVisible || this._doNotRender) {
return false;
}
if (!this.contains(x, y)) {
return false;
}
callback(this);
return true;
}