Mouse/Mobile Input on same project

Hi, I am working on a project which eventually will need full support for mobile devices. I was wondering if I really needed to implement both input methods ? Because right now I coded only the click event of the mouse and not touch or anything and I can click on my entities to select them, but I can’t drag them like I would do with the mouse… Why would the click work but not the drag ? Is it because of using ‘click’ event instead of mouse events ?



Just realized I use the same events for both things… I don’t use ‘click’ event only mousedown and mouseup.

Are you still having trouble with this?

Humm yea, with a mouse everything works perfectly, but on mobile, I can click to pick, i can rotate it but I can’t drag the cube to move it…

In a nutshell, yes. You will need to handle both touch and mouse events.

There’s a few examples of this being done:

1 Like

I’m no expert here, but my experience suggests that most tablets and mobile emulate mouse clicks automagically. It seems that they interpret momentary touches as a mouse click. So button clicks work without doing anything special. In fact, I’ve found that when I enable Touch events, I’ll get behavior that suggests that the app is getting two clicks - one from the emulation and another from the actual Touch event - and I can only counter that (without additional coding) by holding the press extra long on the mobile.

So you will probably have to create some touch events in order to get your press and drag to work.

1 Like

Also, you may want to look at this thread and .preventDefault() for more info on the “double input” and how you might deal with it.

1 Like