forked from IoLanguage/io
/
CheckBox.io
37 lines (31 loc) · 886 Bytes
/
CheckBox.io
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
CheckBox := Button clone do(
position setX(100) setY(100)
isSelected := 0
image := ImageManager item("CheckBox")
altImage := ImageManager item("CheckBoxChecked")
size setWidth(26) setHeight(26)
title := "CheckBox"
motionAction := nil
setImage := method(v, self image := v)
setAltImage := method(v, self altImage := v)
sizeToImage := method(
if (image, self size setWidth(image width) setHeight(image height))
)
sizeToImage
draw := method(
if (self image,
if (isSelected == 0, image draw, if (altImage, altImage draw, image draw))
return
)
)
drawBackground := method(self)
motion := method(
"CheckBox motion\n" print
isSelected := if (self screenHit, 1, 0)
write("isSelected := ", isSelected, "\n")
//if(isSelected == 1,
if (self target and self motionAction, self target perform(motionAction, self))
//)
glutPostRedisplay
)
)