-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.pde
More file actions
55 lines (51 loc) · 1.13 KB
/
Button.pde
File metadata and controls
55 lines (51 loc) · 1.13 KB
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
46
47
48
49
50
51
52
53
54
55
class Button {
float x;
float y;
float xsize;
float ysize;
String text;
String inputText;
Boolean selected = false;
Button(float _x, float _y, float _xsize, float _ysize, String _text) {
x = _x;
y = _y;
xsize = _xsize;
ysize = _ysize;
text = _text;
}
Button(float _x, float _y, float _xsize, float _ysize, String _text, String _inputText) {
x = _x;
y = _y;
xsize = _xsize;
ysize = _ysize;
text = _text;
inputText = _inputText;
}
void display() {
fill(255);
stroke(0);
if (selected) {
stroke(255, 0, 0);
}
if (this.hover()) {
fill(128);
}
textSize(18);
rect(x, y, xsize, ysize);
fill(0);
textSize(18);
textAlign(CENTER, CENTER);
text(text, x + xsize/2, y + ysize/2 - 4);
if (text.equals("") && inputText != null) {
fill(64);
text(inputText, x + xsize/2, y + ysize/2 - 4);
}
}
Boolean hover() {
if (mouseX > x && mouseX < x + xsize && mouseY > y && mouseY < y + ysize) {
return true;
} else {
return false;
}
}
}