mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
[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 commitcb3305a2fc, 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](4c464b3092/website/docs/guides/application-development.mdx (L54)) * add changelog entry per PR template
This commit is contained in:
parent
cb3305a2fc
commit
7b8355a385
2 changed files with 20 additions and 3 deletions
|
|
@ -10,7 +10,21 @@ setting it in the [`Menu`](../reference/options.mdx#menu) application config, or
|
|||
|
||||
An example of how to create a menu, using [the `NewApp` scaffold](../guides/application-development.mdx):
|
||||
|
||||
```go
|
||||
```go title="main.go"
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"runtime"
|
||||
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||
"github.com/wailsapp/wails/v2/pkg/menu/keys"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
rt "github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := NewApp()
|
||||
|
||||
AppMenu := menu.NewMenu()
|
||||
|
|
@ -40,7 +54,10 @@ An example of how to create a menu, using [the `NewApp` scaffold](../guides/appl
|
|||
app,
|
||||
},
|
||||
})
|
||||
// ...
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
It is also possible to dynamically update the menu, by updating the menu struct and calling
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Fixed
|
||||
|
||||
- Updated menu reference docs with complete imports by @agilgur5 in [#4727](https://github.com/wailsapp/wails/pull/4727)
|
||||
- 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)
|
||||
- Fixed menu reference syntax by @agilgur5 in [#4726](https://github.com/wailsapp/wails/pull/4726)
|
||||
- Fixed indentation in Application Development guide by @agilgur5 in [#4730](https://github.com/wailsapp/wails/pull/4730)
|
||||
- Updated Application Development guide to show imports in the `app.go` snippets by @agilgur5 in [#4731](https://github.com/wailsapp/wails/pull/4731)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue