-
Notifications
You must be signed in to change notification settings - Fork 2
/
menu.go
44 lines (42 loc) · 877 Bytes
/
menu.go
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
package faithdroid
type FMenuItem struct {
MyTitle string
MyIcon string
MyOnClick string
MyShowAsAction string
}
type FSubMenu struct {
MyTitle string
MySubMenu []interface{}
}
func MenuItem(title string) *FMenuItem {
mi := &FMenuItem{}
mi.MyTitle = title
return mi
}
func (m *FMenuItem) OnClick(f func()) *FMenuItem {
fnId := NewToken()
m.MyOnClick = fnId
fn:=func(string) string {
f()
return ""
}
GlobalVars.EventHandlersMapLock.Lock()
GlobalVars.EventHandlersMap[fnId] = fn
GlobalVars.EventHandlersMapLock.Unlock()
return m
}
func (m *FMenuItem) Icon(s string) *FMenuItem {
m.MyIcon = s
return m
}
func (m *FMenuItem) ShowAsAction() *FMenuItem {
m.MyShowAsAction = "IF_ROOM"
return m
}
func SubMenu(title string, menuItems ...interface{}) *FSubMenu {
m := &FSubMenu{}
m.MyTitle = title
m.MySubMenu = menuItems
return m
}