Processing Application on a touch screen tablet

Hi,

I have developed an application on processing that I am trying to run on a windows tablet. I am facing problems with its touch screen. It does not detect touch properly and misses it generally. When you tap on the button speedily multiple times the tap gets detected. For example, the application runs perfectly fine if I perform all actions using a double tap instead of a single tab. Why is that? Can anyone please help?

I have used mousePressed for detecting touch.

Also when i run it on my computer using a mouse it works fine with a single click.

Tagged:

Answers

  • I have the exact same problem, and i tried two different computers, both running win8 and the problem is consistent.

    If you sweep the button it detects without any problems, but a single press will not work. But by far the worst problem i have encountered are that if you press one button and then after a while presses another one, sometimes the first one gets pressed, even though you are pressing a button at the other end of the screen. It seems like the cursor is still hovering over that button and that the program somehow detects the press before the position.

    This made me wonder if processing has some way to force the cursor to a given position. One could make the code in such way, that we don't detect buttonpresses but we detect if the mouse are hovering over the button equivalent to a buttonpress. The cursor will flicker between the point on the screen you press and the default position, but once you release it will always be on the default position. And you can just hide the cursor, so the user won't see it flickering. But this requires that there is such a command in processing???

  • I confirm that mouse-activity sucks in Processing with win8.

    The problem come from how Processing handle it - I don't know how it works, but there is an issue somewhere - .

    You have to handle it by yourself, without using the property "mousePressed" , never. The method "mousePressed" looks to work as expected but the property is not stable enough. You should create a local variable/method "mouseIsPressed" in your classes and modify it from the main "mousePressed" method

  • tlecoz could you try to elaborate a bit on that? My biggest problem by far is that the cursor hovers over the last pressed button and if another button is pressed, it will first press the previous button before pressing the selected button. So frustrating. How would one write a function that solves this problem?

  • Oh, I think in your case, the problem come from your code . Can you post it, then we will be able to see what's wrong in it

  • First of thanks for your help. Sometimes i am so consumed by getting things to work that i forget to express my gratitude over how helpful people are :)

    My code are to long and uses serial to communicate with an arduino, but the problem can be recreated by using the example code from the ControlP5 library:

    I do not believe that the error has anything to do with the ControlP5 library. In my sketch i have som buttons that i have drawen from scratch and does not use the controlP5 library. If i press on one with the mouse, there are no problem, but when pressing on the screen i have to swipe the screen instead of pushing to get an accepted press.

    Anyway try this code and see if you get the same result as i have described at the end of the code (can be found in the ControlP5 example library "ControlP5 Button"):

    /**
     * ControlP5 Button
     * this example shows how to create buttons with controlP5.
     * 
     * find a list of public methods available for the Button Controller 
     * at the bottom of this sketch's source code
     *
     * by Andreas Schlegel, 2012
     * www.sojamo.de/libraries/controlp5
     *
     */
    
    import controlP5.*;
    
    ControlP5 cp5;
    
    int myColor = color(255);
    
    int c1,c2;
    
    float n,n1;
    
    
    void setup() {
      size(400,600);
      noStroke();
      cp5 = new ControlP5(this);
    
      // create a new button with name 'buttonA'
      cp5.addButton("colorA")
         .setValue(0)
         .setPosition(100,100)
         .setSize(200,19)
         ;
    
      // and add another 2 buttons
      cp5.addButton("colorB")
         .setValue(100)
         .setPosition(100,120)
         .setSize(200,19)
         ;
    
      cp5.addButton("colorC")
         .setPosition(100,140)
         .setSize(200,19)
         .setValue(0)
         ;
    
      PImage[] imgs = {loadImage("button_a.png"),loadImage("button_b.png"),loadImage("button_c.png")};
      cp5.addButton("play")
         .setValue(128)
         .setPosition(140,300)
         .setImages(imgs)
         .updateSize()
         ;
    
      cp5.addButton("playAgain")
         .setValue(128)
         .setPosition(210,300)
         .setImages(imgs)
         .updateSize()
         ;
    
    }
    
    void draw() {
      background(myColor);
      myColor = lerpColor(c1,c2,n);
      n += (1-n)* 0.1; 
    }
    
    public void controlEvent(ControlEvent theEvent) {
      println(theEvent.getController().getName());
      n = 0;
    }
    
    // function colorA will receive changes from 
    // controller with name colorA
    public void colorA(int theValue) {
      println("a button event from colorA: "+theValue);
      c1 = c2;
      c2 = color(0,160,100);
    }
    
    // function colorB will receive changes from 
    // controller with name colorB
    public void colorB(int theValue) {
      println("a button event from colorB: "+theValue);
      c1 = c2;
      c2 = color(150,0,0);
    }
    
    // function colorC will receive changes from 
    // controller with name colorC
    public void colorC(int theValue) {
      println("a button event from colorC: "+theValue);
      c1 = c2;
      c2 = color(255,255,0);
    }
    
    public void play(int theValue) {
      println("a button event from buttonB: "+theValue);
      c1 = c2;
      c2 = color(0,0,0);
    }
    

    Okay so try to press the ColorA button with the mouse and then the ColorB button. You will se that in the processing text prompt it changes just as expected, First it writes ColorA and then ColorB. Then do the same using the touch screen. You will see that it writes ColorA and then ColorA again, even though you pressed ColorB. A third touch on ColorB will get you the ColorB.

  • Hi, I am facing the exact same problem today with the touchscreen of a Raspberry Pi 3. The problem is that a first tap on the screen sets the (X,Y) position of the mouse pointer (even though it's supposed to be a touch screen and therefore the concept of a mouse pointer is subjected to discussion), while a second tap sets new (X,Y) values, but adds a click event at the former position. This explains why ColorA appears twice before ColorB displays.

    The problem is awful when dealing with Knobs or Toggle buttons: by clicking away from the controller if the "mouse" (equivalently mouseX and mouseY variables) is positioned on the controller, the controller is triggered before the "mouse" is moved (equivalently before mouseX and mouseY are set to new values corresponding to the click away from the controller).

    How could I fix such behavior?

    Thanks!

  • When I used P5Control this problem occurred to me. Then, I changed to 4GP library and it accept one touch as button pressed.

  • Has anyone made any progress on a workaround for this issue with the ControlP5 library? I'm having the same issues with touch input on Windows that palmhoej and jellium described.

Sign In or Register to comment.