about summary refs log tree commit diff stats
path: root/button.lua
blob: c495b5ff02e11034f151d95b5f58a964ba2e92cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
button_handlers = {}

-- draw button and queue up event handlers
function button(name, params)
  love.graphics.setColor(params.color[1], params.color[2], params.color[3])
  love.graphics.rectangle('fill', params.x,params.y, params.w,params.h, 5,5)
  if params.icon then params.icon(params.x, params.y) end
  table.insert(button_handlers, params)
end

-- process button event handlers
function propagate_to_button_handers(x, y, button)
  for _,ev in ipairs(button_handlers) do
    if x>ev.x and x<ev.x+ev.w and y>ev.y and y<ev.y+ev.h then
      if ev.onpress1 and button == 1 then ev.onpress1() end
    end
  end
end
t; 2021-02-11 19:34:55 -0800 7723 - baremetal: rendering string values' href='/akkartik/mu/commit/baremetal/411string.mu?h=hlt&id=d1bcd1421f7a0e87105499a738bae3b3a5c92de9'>d1bcd142 ^
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125