Sign in to follow this  
3Dlove

Trigger / Simulate a mousedown on canvas

Recommended Posts

Hello guys,

 

I try to simulate a mouse click with jQuery :

 

I can catch the event with jQuery but Babylonjs doesn't catch it with scene.onPointerDown

 

 

Here is my code :

var x_coord = 918, y_coord = 549;window.myevent = $.Event( "mousedown", { pageX: x_coord, pageY: y_coord } );$(scene._engine.getRenderingCanvas()).trigger(myevent);
 
Any ideas ?
 
Have a nice day ;-)

Share this post


Link to post
Share on other sites

Here is the solution:

var x= 918, y= 549;var element = scene._engine.getRenderingCanvas();var clickEvent = document.createEvent("MouseEvents");clickEvent.initMouseEvent("mousedown", true, true, window, 0, 0, 0, x, y, false, false, false, false, 0, null);element.dispatchEvent(clickEvent); 

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.