Skip to content

Commit 7b8355a

Browse files
authored
[v2] docs(menu): add imports and complete the example (post merge conflict) (#4742)
* [v2] docs(menu): add imports and complete the example (post merge conflict) This partially redoes commit cb3305a, as a merge conflict resolution seemed to have accidentally removed a large portion of the changes - the example was missing imports, which [confused a user](https://stackoverflow.com/q/79827619/3431180), particularly due to the `rt` import alias - plus there are a good number of imports too, which this makes explicit - also give this file the title `menu.go` for clarity / explicitness, particularly to differentiate from the `NewApp` / `app.go` scaffold - also handle the error at the end similar to [existing examples](https://github.com/wailsapp/wails/blob/4c464b3092fff35b993f31ca62ca612399dde970/website/docs/guides/application-development.mdx?plain=1#L54) * add changelog entry per PR template
1 parent cb3305a commit 7b8355a

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

website/docs/reference/menus.mdx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,21 @@ setting it in the [`Menu`](../reference/options.mdx#menu) application config, or
1010

1111
An example of how to create a menu, using [the `NewApp` scaffold](../guides/application-development.mdx):
1212

13-
```go
13+
```go title="main.go"
14+
package main
15+
16+
import (
17+
"log"
18+
"runtime"
19+
20+
"github.com/wailsapp/wails/v2"
21+
"github.com/wailsapp/wails/v2/pkg/menu"
22+
"github.com/wailsapp/wails/v2/pkg/menu/keys"
23+
"github.com/wailsapp/wails/v2/pkg/options"
24+
rt "github.com/wailsapp/wails/v2/pkg/runtime"
25+
)
26+
27+
func main() {
1428
app := NewApp()
1529

1630
AppMenu := menu.NewMenu()
@@ -40,7 +54,10 @@ An example of how to create a menu, using [the `NewApp` scaffold](../guides/appl
4054
app,
4155
},
4256
})
43-
// ...
57+
if err != nil {
58+
log.Fatal(err)
59+
}
60+
}
4461
```
4562

4663
It is also possible to dynamically update the menu, by updating the menu struct and calling

website/src/pages/changelog.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Fixed
1818

19-
- Updated menu reference docs with complete imports by @agilgur5 in [#4727](https://github.com/wailsapp/wails/pull/4727)
19+
- Updated menu reference docs with complete imports by @agilgur5 in [#4727](https://github.com/wailsapp/wails/pull/4727) and [#4742](https://github.com/wailsapp/wails/pull/4742)
2020
- Fixed menu reference syntax by @agilgur5 in [#4726](https://github.com/wailsapp/wails/pull/4726)
2121
- Fixed indentation in Application Development guide by @agilgur5 in [#4730](https://github.com/wailsapp/wails/pull/4730)
2222
- Updated Application Development guide to show imports in the `app.go` snippets by @agilgur5 in [#4731](https://github.com/wailsapp/wails/pull/4731)

0 commit comments

Comments
 (0)