-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextBox.pde
More file actions
45 lines (45 loc) · 1014 Bytes
/
Copy pathTextBox.pde
File metadata and controls
45 lines (45 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class TextBox {
PGraphics text;
boolean selected;
String content="", header;
int x, y, w, h;
TextBox(String _header, int _x, int _y, int _w, int _h) {
header=_header;
x=_x;
y=_y;
w=_w;
h=_h;
text=createGraphics(w-1, h-1);
}
PGraphics display(boolean display) {
if(mouseClicked) {
if(button("", x, y, w, h, 0)) {
selected=true;
} else selected=false;
}
text.beginDraw();
text.textAlign(LEFT);
text.textSize(30);
text.fill(255);
text.rect(0, 0, w, h);
text.fill(0);
text.text(header, 0, -22, w, h);
text.text(content, 5, 0, w, h);
text.endDraw();
if(display) image(text, x, y);
return text;
}
void updateText() {
if(selected) {
if (key==BACKSPACE) {
if(0<content.length()) {
content=content.substring(0, content.length()-1);
}
} else if(key!=CODED&&key!=ENTER)
{
content=content+key;
}
}
}
String getContent() { return content; }
}