Ketai onPinch() Not Working

edited August 2014 in Library Questions

I've been working on integrating some of my existing Processing sketches with Android, and I have been making use of the Ketai library which has been very helpful so far. However, I have been unable to get the onPinch() function to execute. To test it, I wrote a pinch sketch which is also not working.

import ketai.ui.*;

float ellipseWidth = 50;
float ellipseHeight = 50;
KetaiGesture gesture;

void setup() {
  size(displayWidth, displayHeight);
  println("println works fine");
  KetaiAlertDialog.popup(this, "Test", "Other parts of Ketai work fine.");
}

void draw() {
  orientation(PORTRAIT);
  background(0);
  fill(0);
  stroke(255);
  ellipse(width/2, height/2, ellipseWidth, ellipseHeight);
}

void onPinch (float x, float y, float d) {
  println("Pinched");
  ellipseWidth += d;
  ellipseHeight += d;
}

I cannot find anything useful about this in the documentation (here) and I have done essentially the same thing that worked here so all that can still be wrong is related to my configuration unless I have missed something obvious.

Answers

  • The problem persists across any programs I try to make using those Ketai functions.

  • //Try importing the MotionEvent class directly from android.
    import android.view.MotionEvent;
    
    void setup() {
      //Add this line to the setup function
      gesture = new KetaiGesture(this);
    }
    
    //Add this function at the bottom of the script to listen for surface touch events
    public boolean surfaceTouchEvent(MotionEvent event) {
      //Call this to keep mouseX and mouseY updated
      super.surfaceTouchEvent(event);
    
      //Forward the event to the class for processing
      return gesture.surfaceTouchEvent(event);
    }
    

    That should do the trick! ;)

Sign In or Register to comment.