I have this simple sketch in Processing in a file called tmp.pde
:
void setup() {
size( 640,480 );
}
void draw() {
color bg = color(200);
background(bg);
}
void mouseReleased() {
println("(" + mouseX + ", " + mouseY + ")");
}
It runs perfectly in desktop (Java) mode. It also works perfectly in Javascript when viewed on a browser on the desktop.
Yet when I try and run it on the iPad, the first finger tap, wherever it happens on the canvas yields mouseX
and mouseY
of (0, 0)
. Later taps return the correct coordinates but this first click is causing untold inconvenience as it upsets later calculations.
I have experimented with loading jQuery using a custom template to do so, then giving focus to the canvas, thus:
$(document).ready(function(){
$('#tmp').focus();
});
I have also looked at both these questions: Detect mouse click location within canvas and Getting mouse location in canvas but they both deal with detecting the mouse location within JavaScript while I need to integrate the results in Processing.
I would appreciate any pointers.
iPad Setup
- I am running the app on my desktop browser on a given port, say
http://127.0.0.1:52956
- I use
ifconfig
to get my computer's IP address. In this case:192.168.1.10
- With the iPad on the same wifi network, I point the browser to
http://192.168.1.10:52956
Finally in case anyone is interested to see the consequences of this problem, my app is running here: http://bit.ly/facebuzzapp and you can see that it works well on desktop but not on iPad.