Android controlP5 button issue

In Android is producing a strange behavior.
Need to click twice, one for highlight and other to call the action.

Also if a button is highlighted and you press in other part of the screen, the result is that the button highlighted is pressed.

is there any solution for this i saw many topics over google complaining this wrong

thanks in advance

Same here. On desktop in javaMode all works great but on the device the behaviour of the controller CP5 is not consistent.

i am trying to solve it this give some results but not accurate

void draw() {

 if (mousePressed == true) {
 setLock(controlP5.getController("slider1"), false);

  
  }
  else { 
 
   if (mousePressed == false) {
   setLock(controlP5.getController("slider2"), true);
 }
}
}

Same here, i tried lot of things, even double clicks, callbacklisteners with no luck…
In the end, what worked best for me is to check that mouse click is inside button’s position:

public void  mousePressed(){
      if (mouseX >= GUIBut_1.getPosition()[0] && mouseX <= GUIBut_1.getPosition()[0] + GUIBut_1.getWidth() && mouseY >= GUIBut_1.getPosition()[1] && mouseY <= GUIBut_1.getPosition()[1] + GUIBut_1.getHeight()){
          GUITxt_1.setText("BOTON1");
          Audio1.play();
      }
      else if (mouseX >= GUIBut_2.getPosition()[0] && mouseX <= GUIBut_2.getPosition()[0] + GUIBut_2.getWidth() && mouseY >= GUIBut_2.getPosition()[1] && mouseY <= GUIBut_2.getPosition()[1] + GUIBut_2.getHeight()){
          GUITxt_1.setText("BOTON2");
          Audio2.play();
      }
  }

@acalleja

Hi I have found solution for this issue :slightly_smiling_face::slightly_smiling_face::slightly_smiling_face:

@acalleja

Read this

No, this library also does not work. at least with buttons. I need to touch twice, and if I insert those two lines, most of the times I cannot select different values from a Drop Down list.

Hi
I have try it with slider And button it’s working with out issue

Thanks for your answer. I did try it, and I do need to touch it twice to make it do whatever it needs to do. Would you help me find out why? I downloaded the rar file you posted and extracted the folder to the documents/processing/libraries folder. compiled the button example, and the problem was still there.
If I can’t make this work, I won’t be able to create a gui for my midi controller :frowning: I already have done it for windows and would like to create the same for android as well.
Thank You.

If I can’t make this work, I won’t be able to create a gui for my midi controller

Have you considered making your own controls; it’s not all that difficult.

Hi, thanks for your answer. I have seen the “Ketai” library that seems to work more or less that way, at least for buttons, but how would I do a drop down list that way? I am a complete beginner with processing. Perhaps on touch screen devices I should rethink the user interface. If you follow the link below, you can download and open the editor I have created (windows only). The iLoopino guitar effects controller project is free for everyone to build, it is not a product, so the editor is not perfect, it is what my limited knowledge allowed me to do :slight_smile:
But now I would like to edit the controller also over bluetooth. That part I think I have more or less sorted.
perhaps I would have to use popup lists instead of the drop down boxes. Or learn how to create them, but I will need help with that :frowning:
Thanks

Hi
When you touch twice the button works or the slider with out effects on other buttons I mean is it normal active ON/OFF touch/released ??

With example I provided someone solved the button/slider issue as he said and as happened with me

Unfortunately I don’t have a 64-bit windows box and was unable to run your editor; perhaps a screenshot so I can see what types of controls you are using. Is the android device a phone or a tablet? Is the bluetooth classic or LE? The following source code runs on an android tablet and may be something that you could use. I also have code for simple push buttons and a stepper with up/down arrows.

/*
 Demonstrates drop down list for Android.
*/

 // Drop Down List control parts => a.)display field, b.)arrow, c.)listItems
final int _displayX =  100;
final int _displayY = 120;
final int _displayW = 500;
final int _displayH = 70;
final int _itemH = 70;
final int _arrwX = _displayX + _displayW;
final int _arrwY = _displayY;
final int _arrwSize = _displayH;

boolean drop;
color BLUE = color(64,124,188);
color GREEN = color(0,126,0);
String[] fruit = {"Apples","Peaches","Oranges","Bananas","Pears"};
int[] _itemY;
int selectedItem = -1;
 
class List {
 
 void press(float mx, float my){
   // arrow touches
   if((mx >= _arrwX) && (mx <= _arrwX+_arrwSize) && (my >= _arrwY) && (my <= _arrwY+_arrwSize)){
   if(drop == true){
     drop = false;
    } else {
    drop = true;
   }
   } // list touches
   if (fruit.length > 0) {
   for(int j = 0; j < fruit.length; j++){
    if((mx >= _displayX) && (mx <= _displayX + _displayW) && (my >= _itemY[j] ) && (my <= _itemY[j] + _itemH)) {
     selectedItem = j;
     drop = false;
    } 
   }
  }
 } 
  
 void displayFieldString(String str) {
  fill(255); // display field background color
  rect(_displayX,_displayY,_displayW,_displayH);
  fill(0); // text color
  textSize(42);
  text(str, _displayX + 10, _displayY + 15, _displayW, _displayH);
 }
  
 void display(){
  // display field
 if(selectedItem == -1){
   displayFieldString("Select fruit:");  
   } else {
   displayFieldString(fruit[selectedItem]);
  }
  // arrow
  fill(255); // arrow background color
  rect(_arrwX, _arrwY, _arrwSize, _arrwSize);
  fill(GREEN); // arrow color
  triangle(_arrwX+5, _arrwY+5, _arrwX+_arrwSize-5, _arrwY+5, _arrwX+_arrwSize/2, _arrwY+_arrwSize-5);
  // listItems
  if (drop == true){
   if (fruit.length > 0) {
   // list items  
   _itemY = new int[fruit.length];
   for(int j = 0; j < fruit.length; j++){
    _itemY[j] = (_displayY + _displayH) + j*_itemH;      
    fill(255);
    rect(_displayX,_itemY[j],_displayW,_itemH);
    fill(0);
    textSize(42);
    text(fruit[j], _displayX + 10, _itemY[j] + 15, _displayW, _itemH);
   }  
  }
 }
 } 
  
}

List list;

void setup() {
 fullScreen();
 orientation(LANDSCAPE);    
 list = new List();
 drop = false;
}

void draw() {
 background(BLUE);  
 list.display();
}

void mousePressed(){
 list.press(mouseX, mouseY);
}
1 Like