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:
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.
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 I already have done it for windows and would like to create the same for android as well.
Thank You.
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
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
Thanks
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);
}