-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathbutton.go
More file actions
50 lines (37 loc) · 768 Bytes
/
button.go
File metadata and controls
50 lines (37 loc) · 768 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
40
41
42
43
44
45
46
47
48
49
50
//+build windows
package wui
import "github.com/gonutz/w32/v2"
func NewButton() *Button {
return &Button{}
}
type Button struct {
textControl
onClick func()
}
var _ Control = (*Button)(nil)
func (*Button) canFocus() bool {
return true
}
func (b *Button) OnTabFocus() func() {
return b.onTabFocus
}
func (b *Button) SetOnTabFocus(f func()) {
b.onTabFocus = f
}
func (*Button) eatsTabs() bool {
return false
}
func (b *Button) OnClick() func() {
return b.onClick
}
func (b *Button) SetOnClick(f func()) {
b.onClick = f
}
func (b *Button) create(id int) {
b.textControl.create(id, 0, "BUTTON", w32.WS_TABSTOP|w32.BS_PUSHBUTTON)
}
func (b *Button) handleNotification(cmd uintptr) {
if cmd == w32.BN_CLICKED && b.onClick != nil {
b.onClick()
}
}