In this code bellow i tried to load different texts(defferent names) from a list after touching the "Details" button on my device..The problem is that it shows me the name only fore some seconds but i want to stay there invariably..
import ketai.ui.*;
import android.view.MotionEvent;
Button on_button; // the button
int clk = 1;
KetaiGesture gesture;
KetaiList klist;
KetaiList selectionlist;
ArrayList<String> textlist = new ArrayList<String>();
void setup() {
size(1000,600);
orientation(LANDSCAPE);
textSize(28);
textAlign(CENTER);
gesture = new KetaiGesture(this);
on_button = new Button("Details", 820, 420, 100, 50);
textlist.add("Patient 1");
textlist.add("Patient 2");
textlist.add("Patient 3");
textlist.add("Patient 4");
textlist.add("Patient 15");
}
void mousePressed()
{
if (on_button.MouseIsOver()) {
selectionlist = new KetaiList(this,textlist);
}
}
void onKetaiListSelection(KetaiList klist)
{
String selection = klist.getSelection();
if (selection == "Patient 1")
fill(150);
text("Kathy Smith",30,40);
if (selection == "Patient 2")
fill(150);
text("John Doe",30,40);
if (selection == "Patient 3")
fill(150);
text("Sue White",30,40);
// if (selection == "Patient 4")
}
void draw() {
background(255);
on_button.Draw();
}
// ==========================================================
class Button {
String label; // button label
float x; // top left corner x position
float y; // top left corner y position
float w; // width of button
float h; // height of button
// constructor
Button(String labelB, float xpos, float ypos, float widthB, float heightB) {
label = labelB;
x = xpos;
y = ypos;
w = widthB;
h = heightB;
}
void Draw() {
fill(150);
stroke(141);
rect(x, y, w, h, 10);
textAlign(CENTER, CENTER);
fill(0);
text(label, x + (w / 2), y + (h / 2));
}
boolean MouseIsOver() {
if (mouseX > x && mouseX < (x + w) && mouseY > y && mouseY < (y + h)) {
return true;
}
return false;
}
public boolean surfaceTouchEvent(MotionEvent event) {
// Call to keep mouseX and mouseY constants updated
//super.surfaceTouchEvent(event);
// Forward events
return gesture.surfaceTouchEvent(event);
}
}