ozRocker Posted July 2, 2016 Share Posted July 2, 2016 Does anyone know how to use pointer events to detect double-tap and double-click? I'm using the pep.js framework and can't see anything in there. Basically I just want to be able to double-tap my meshes on the screen to select them. The dblClick event runs beautifully on desktop but unfortunately there is no equivalent for mobile devices. I realise I could write my own with a timer but I was hoping to make my code a lot cleaner by using a single event. Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted July 3, 2016 Share Posted July 3, 2016 Hi ozRocker, i don't believe such a event exists, i have never seen it anyhow. but here's one rather easy way of doing it without being too messy I haven't tested it, so it'll probably need a little bit tweaking to the timing, etc, but it should work just fine, and if you're using 2.5 alpha you'll need to use the "new" way to handle pointer events^^ var leftClicks = 0; scene.onPointerDown = function(evt /*, pickResult*/ ) { if (!scene.isReady()) return; if (evt.button === 0) { var noDoubles = function() { leftClicks = 0 }, tOut; return function() { //if no left clicks are made within 100ms of the previous click, reset leftClicks to 0. clearTimeout(tOut); tOut = setTimeout(noDoubles, 100); }; leftClicks++; if (leftClicks === 2) { //2 fast clicks } } else if (evt.button === 2) { //right click } else { //mouse wheel } }; Quote Link to comment Share on other sites More sharing options...
ozRocker Posted July 3, 2016 Author Share Posted July 3, 2016 Thanx mate. Yeh, I decided to just use a timer. No biggie Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.