Detect touch event in Processing for Android

Last exercise demonstrate the basic "Hello World of Processing for Android". This exercise show to to detect touch event, by implement surfaceTouchEvent() method.

Detect touch event in Processing for Android

import android.view.MotionEvent;

boolean showEvent = false;
int evAction;
int evX, evY;

void setup()
size(displayWidth, displayHeight);


void draw()
text("Action: " + str(evAction), 10, 50);
ellipse(evX, evY, 10, 10);

showEvent = false;

public boolean surfaceTouchEvent(MotionEvent event)
evAction = event.getAction();
evX = mouseX;
evY = mouseY;
showEvent = true;

return super.surfaceTouchEvent(event);