-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSUIButton.gml
More file actions
40 lines (34 loc) · 933 Bytes
/
Copy pathSUIButton.gml
File metadata and controls
40 lines (34 loc) · 933 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
///@function SUIButton
///@param {Real|Struct} x
///@param {Real|Struct} y
///@param {String|Struct} text
///@param {Function|Struct} onClick
///@param {Struct} props
///@param {Array} children
function SUIButton(x, y, text, onClick, props = {}, children = []) : SUI_ELEMENT {
self.text = text
self.onClick = onClick
self.w = 128
self.h = 48
SUIInherit(self, props)
init = function() {
self.box_element = self.appendChild(new SUIBox(0, 0, self.w, self.h, {hoverable: false }))
with(self.box_element) {
border_w = 2
border_color = c_white
border_alpha = 1
bg_alpha = 0
}
self.text_element = self.appendChild(new SUIText(get("w")/2, get("h")/2, text, { hoverable: false, halign: fa_center, valign: fa_middle }))
}
predraw = function(_x, _y) {
self.forEach(function(el) {
if (clicked) {
el.set("y", el.get("ystart") + 3)
}
else {
el.set("y", el.get("ystart"))
}
})
}
}