Mouse Event

Hi Guyz is there any way to catch mouse move value outside the Iframe?

Hi @Jack,

You can use the regular mouse move browser event directly on the window element or any other element of yours. PlayCanvas internally encapsulates and uses the same event.

@Leonidas you have any example in playcanvas

please tell me i am waiting

Please be patient. Many of the posters and users and helping as part of their free time.

okay okay

With your problem, is the PlayCanvas project in an iframe and you are trying to get the mouse event of the parent page?

yes

@yaustar yes

If that’s the case I am not sure it’s going to work, getting the parent window mouse event from the iframe. It may work if both the parent and iframe are hosted under the same domain name and there are no x-frame violations.

Another way to approach this and it will definitely work is to catch the mouse event normally in the parent page and send a message each time it fires with the related info to the iframe using post message.

Here is a manual page on how communication between the parent window with the iframe can work:

https://developer.playcanvas.com/en/user-manual/publishing/web/communicating-webpage/#embedded-in-iframe

1 Like

@Leonidas @yaustar when i out side the I frame and mouse down when I come back on I frame how I get mouse position ?


Please check when i go outside and come to iframe there no mouse event fire

I believe that it is because you are dragging something from the parent window and therefore not interacting with the iframe of PlayCanvas

You may be better off to not use the iframe and have the PlayCanvas canvas on the same page as your HTML UI (see this thread: Embedding PlayCanvas into a webpage without iframe)

1 Like