How can i use switch(mouseButton) in android mode?

edited November 2015 in Android Mode

Hi, this is the part of my code that works on java mode, but obviously it doesn't work in android mode, so my question is, can i use this kind of switch on my android project? How can i make this work? I tried to change the mouse button with mouse pressed but i understood that i cannot use a boolean in a switch. This is the error that occurs every time (5 equals errors):


  1. ERROR in /private/var/folders/7h/__943dks5895p0qs_txz9p700000gn/T/android1454252317288703044sketch/src/processing/test/catchme/CatchMe.java (at line 101) switch(mouseButton) { ^^^^^^^^^^^

mouseButton cannot be resolved to a variable

This is the part of code of the first error:


void draw(){ // state if(mousePressed){ if(state == stateMenu){ if (rectOver) { switch(mouseButton) { case LEFT: state = statePlay; break; case RIGHT: state =stateLost; break; case ESC: // quit exit(); break; default: // do nothing break; } } }

}

Answers

  • I guess that mouseButton can not be used in android mode.
    What is this supposed to do? How do you right-click on a smartphone?
    (new iPhone doesn' t count...)

  • Yes, mouseButton isn't available for touch devices, but you could use onLongPress() (for example) from the Ketai library as a substitute for right-click.

  • I know that i cannot use mouseButton, i didn't suppose to right click on a smartphone. My question was about how can i use the switch button on an android device, because i used it in a java project, and i need to convert it. like: My code

    Can i use like: With onLongPress()

  • @MarcoReverse=== what version of processing??? as for android you can use SimpleOnGestureListener, which detects a lot of motionevents (tap, doubletap, fling...)...

  • @akenator i've processing 3.0. but can i put the motion events in the switch?

  • @MarcoReverse== it worked with P2; never tried with P3. But why not??? - i ll see that ASAP.

Sign In or Register to comment.