Jump to content

MouseClick event on FireFox


shaharyar.ahmed
 Share

Recommended Posts

Mouse click event is not working on Mozilla FireFox. It is not picking any mesh. But if I click on empty area it raises the event.

 

It's working fine on Chrome and Internet explorer 11.

 

 

Code:

 

renderCanvas.addEventListener("click", function (evt) {// We try to pick an objectvar pickResult = newScene.pick(evt.offsetX, evt.offsetY);// if the click hits the ground object, we change the impact positionif (pickResult.hit) {document.getElementById('status').innerHTML = pickResult.pickedMesh.name;}elsedocument.getElementById('status').innerHTML = 'Nothing Selected';});

You can check it here

Link to comment
Share on other sites

Hi, you can try this :

renderCanvas.addEventListener("click", function (evt) {    //offsetX/Y are not implemented on FireFox    var offsetX = (e.offsetX || e.clientX - $(e.target).offset().left + window.pageXOffset );    var offsetY = (e.offsetY || e.clientY - $(e.target).offset().top + window.pageYOffset );        var pickResult = newScene.pick(offsetX, offsetY);    // if the click hits the ground object, we change the impact position    if (pickResult.hit) {        document.getElementById('status').innerHTML = pickResult.pickedMesh.name;    }    else        document.getElementById('status').innerHTML = 'Nothing Selected';});

I've found this trick by quickly searching on Google, on this topic : http://stackoverflow.com/questions/11334452/event-offsetx-in-firefox

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...