Add some menus
This commit is contained in:
parent
8888825844
commit
994e432891
@ -44,6 +44,43 @@ func main() {
|
||||
Centered: false,
|
||||
})
|
||||
|
||||
menu := app.NewMenu()
|
||||
fileMenu := menu.AddSubmenu("File")
|
||||
fileMenu.AddRole(application.NewFile)
|
||||
fileMenu.AddRole(application.Open)
|
||||
fileMenu.Append(application.NewFileMenu().GetSubmenu())
|
||||
menu.FindByRole(application.NewFile).OnClick(func(ctx *application.Context) {
|
||||
d := application.SaveFileDialog()
|
||||
d.SetOptions(&application.SaveFileDialogOptions{
|
||||
Filters: []application.FileFilter{
|
||||
{DisplayName: "Peachy database", Pattern: "*.pit"},
|
||||
{DisplayName: "All Files", Pattern: "*.*"},
|
||||
},
|
||||
AllowOtherFileTypes: true,
|
||||
Title: "Create new database",
|
||||
})
|
||||
path, err := d.PromptForSingleSelection()
|
||||
if err != nil {
|
||||
application.InfoDialog().SetMessage("Error: " + err.Error()).Show()
|
||||
}
|
||||
if path != "" {
|
||||
application.InfoDialog().SetMessage(path).Show()
|
||||
} else {
|
||||
application.InfoDialog().SetMessage("No file selected").Show()
|
||||
}
|
||||
})
|
||||
menu.FindByRole(application.Open).OnClick(func(ctx *application.Context) {
|
||||
path, _ := application.OpenFileDialog().
|
||||
CanChooseFiles(true).
|
||||
PromptForSingleSelection()
|
||||
if path != "" {
|
||||
application.InfoDialog().SetMessage(path).Show()
|
||||
} else {
|
||||
application.InfoDialog().SetMessage("No file selected").Show()
|
||||
}
|
||||
})
|
||||
app.SetMenu(menu)
|
||||
|
||||
err := app.Run()
|
||||
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user