First mousePressed() ignored

Home Forums Procoding First mousePressed() ignored

This topic contains 1 reply, has 1 voice, and was last updated by  audiocommander 6 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #801

    John Cartan

    I’ve had this problem in every sketch I’ve written. I use mousePressed and mouseDragged handlers to detect mouseDown/touch events and update the screen as user drags. The first mouseDown/touch is always ignored. But subsequent touches and drags work just fine.

    As near as I can tell mousePressed is not even called the first time. Your sample linedraw sketch has the same issue. The Paper and Javascripts samples do not have this problem, onlu the Processing.js sketches.

    The workaround is to just let users fail on the first touch and hooe they try a second time, but that’s pretty lame.

    Any ideas?

    Thanks!

    #802

    audiocommander
    Keymaster

    Hi John,

    this only happens for touch events and is a known issue of Processing.js. Apparently it’s still there in 1.4.1.
    https://processing-js.lighthouseapp.com/projects/41284/tickets/1927-first-touchstart-on-a-multitouch-application
    I’m not sure how good the fix is; in my experience it’s very dangerous to fix one line in processing.js as something may go terribly wrong on another line at the other end of the file.

    Unfortunately, I just updated to Processing.js 1.4.1, the next update will continue the latest Processing.js version. So, I fear you either have to use your own Processing.js version (just put it with exactly that name in the user documents folder of your iOS device) or wait until it gets fixed in Processing.js.

    I haven’t tried, but you might apply a fix if you add a .js resource that intercepts touchStart() events and forward that to the sketch instance (see the touches.js demo how to receive touch events). You get the current sketch instances with “Processing.instances”, in Procoding, your sketch is almost anytime “Processing.instances[0]”. Maybe you can also mess around with the Processing sketch instance to trigger a first event there?. I’m pretty sure though, that it’s impossible to virtually generate a “pseudo native” iOS touch input event, as those first user inputs are quite crucial (for example if sound will be loaded and played); I’m sure that Webkit doesn’t allow for a programmatical creation of touch input events to hinder people from loading huge sound files.

    Hope this helps a bit,
    Michael

    Edit: forgot the link

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘First mousePressed() ignored’ is closed to new replies.