Sign in to follow this  
SamYan

Detect click in children container

Recommended Posts

Hi,

Can anyone tell me please what the best way to hide a "BETTING CONFIGURATION" container by clicking anywhere on the screen other than that container? Actually i'm detecting the mouse coordinates and comparing with the window / container coordinates, but it's good practice?

 

public static isColliding(mouse: any, object: any): boolean {
	return !(mouse.x < object.x || mouse.x > (object.x + object.width) || mouse.y < object.y || mouse.y > (object.y + object.height));
}

this.baseContainer.interactive = true;
this.baseContainer.addListener('pointerdown', () => {
	if (Utils.isColliding(this.mouseCoord, betConfigUI)) {
		console.log('you are in window space');
	} else {
		console.log('you are not in the window space');
	}
})

 

image.png.4043c1a432e7a9e559a7bcb2802ab8e3.png

 

Thanks in advance!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.