-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.go
executable file
·46 lines (39 loc) · 979 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
45
46
package main
import (
"github.com/murlokswarm/app"
"github.com/murlokswarm/log"
)
// AppMainMenu implements app.Componer interface.
type AppMainMenu struct {
CustomTitle string
Disabled bool
}
func (m *AppMainMenu) Render() string {
return `
<menu>
<menu label="app">
<menuitem label="Quit" shortcut="meta+q" selector="terminate:" />
</menu>
<WindowMenu />
</menu>
`
}
// OnCustomMenuClick is the handler called when an onclick event occurs in a menuitem.
func (m *AppMainMenu) OnCustomMenuClick() {
log.Info("OnCustomMenuClick")
}
// WindowMenu implements app.Componer interface.
// It's another component which will be nested inside the AppMenu component.
type WindowMenu struct {
}
func (m *WindowMenu) Render() string {
return `
<menu label="Window">
<menuitem label="Close" selector="performClose:" shortcut="meta+w" />
</menu>
`
}
func init() {
app.RegisterComponent(&AppMainMenu{})
app.RegisterComponent(&WindowMenu{})
}