Jump to content

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!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...