@@ -17,11 +17,19 @@ func (c *Context) Button(text string) EventHandler {
17
17
pc := caller ()
18
18
id := c .idFromCaller (pc )
19
19
return c .wrapEventHandlerAndError (func () (EventHandler , error ) {
20
- return c .button (text , optionAlignCenter , id )
20
+ return c .button (text , iconNone , optionAlignCenter , id )
21
21
})
22
22
}
23
23
24
- func (c * Context ) button (text string , opt option , id widgetID ) (EventHandler , error ) {
24
+ func (c * Context ) iconButton (icon icon ) EventHandler {
25
+ pc := caller ()
26
+ id := c .idFromCaller (pc )
27
+ return c .wrapEventHandlerAndError (func () (EventHandler , error ) {
28
+ return c .button ("" , icon , optionAlignCenter , id )
29
+ })
30
+ }
31
+
32
+ func (c * Context ) button (text string , icon icon , opt option , id widgetID ) (EventHandler , error ) {
25
33
return c .widget (id , opt , nil , func (bounds image.Rectangle , wasFocused bool ) EventHandler {
26
34
var e EventHandler
27
35
if c .pointing .justPressed () && c .focus == id {
@@ -33,5 +41,8 @@ func (c *Context) button(text string, opt option, id widgetID) (EventHandler, er
33
41
if len (text ) > 0 {
34
42
c .drawWidgetText (text , bounds , colorText , opt )
35
43
}
44
+ if icon != iconNone {
45
+ c .drawIcon (icon , bounds , c .style ().colors [colorText ])
46
+ }
36
47
})
37
48
}
0 commit comments