@@ -19,47 +19,58 @@ func main() {
19
19
}
20
20
fmt .Printf ("Found device [%s]\n " , sd .GetName ())
21
21
22
+ // Button in position 2, changes to "Bye!" at the end of the program
23
+ // When pressed, this prints "You pressed me" to the terminal
22
24
myButton := buttons .NewTextButton ("Hi world" )
23
25
myButton .SetActionHandler (& actionhandlers.TextPrintAction {Label : "You pressed me" })
24
26
sd .AddButton (2 , myButton )
25
27
28
+ // Button in position 3, prints "5" to the terminal when pressed
26
29
myOtherButton := buttons .NewTextButton ("4" )
27
30
myOtherButton .SetActionHandler (& actionhandlers.NumberPrintAction {Number : 5 })
28
31
sd .AddButton (3 , myOtherButton )
29
32
33
+ // Button in position 7 (top right on Streamdeck XL), says 7
34
+ // When pressed, changes to display "8"
30
35
myNextButton := buttons .NewTextButton ("7" )
31
36
myNextButton .SetActionHandler (& actionhandlers.TextLabelChangeAction {NewLabel : "8" })
32
37
sd .AddButton (7 , myNextButton )
33
38
39
+ // Image button, no action handler
34
40
anotherButton , err := buttons .NewImageFileButton ("examples/test/play.jpg" )
35
41
if err != nil {
36
42
panic (err )
37
43
}
38
44
sd .AddButton (9 , anotherButton )
39
45
46
+ // Yellow button, no action handler but it goes to blue at the end of the program
40
47
cButton := buttons .NewColourButton (color.RGBA {255 , 255 , 0 , 255 })
41
48
sd .AddButton (26 , cButton )
42
49
50
+ // One button, two actions (uses ChainedAction)
51
+ // Purple button, prints to the console and turns red when pressed
43
52
multiActionButton := buttons .NewColourButton (color.RGBA {255 , 0 , 255 , 255 })
44
53
thisActionHandler := & actionhandlers.ChainedAction {}
45
54
thisActionHandler .AddAction (& actionhandlers.TextPrintAction {Label : "Purple press" })
46
55
thisActionHandler .AddAction (& actionhandlers.ColourChangeAction {NewColour : color.RGBA {255 , 0 , 0 , 255 }})
47
56
multiActionButton .SetActionHandler (thisActionHandler )
48
57
sd .AddButton (27 , multiActionButton )
49
58
59
+ // Text button, gets a red highlight after 2 seconds, then a green
60
+ // highlight after another 2 seconds
50
61
decoratedButton := buttons .NewTextButton ("ABC" )
51
62
sd .AddButton (19 , decoratedButton )
52
-
53
63
time .Sleep (2 * time .Second )
54
64
decorator1 := decorators .NewBorder (10 , color.RGBA {0 , 255 , 0 , 255 })
55
65
sd .SetDecorator (19 , decorator1 )
56
66
time .Sleep (2 * time .Second )
57
67
decorator2 := decorators .NewBorder (5 , color.RGBA {255 , 0 , 0 , 255 })
58
68
sd .SetDecorator (19 , decorator2 )
59
-
60
69
time .Sleep (2 * time .Second )
61
70
71
+ // When this button says "Bye!", the program ends
62
72
myButton .SetText ("Bye!" )
73
+ // When this button goes blue, the program ends
63
74
cButton .SetColour (color.RGBA {0 , 255 , 255 , 255 })
64
75
sd .UnsetDecorator (19 )
65
76
}
0 commit comments