mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-06 17:01:33 +08:00
[v3 windows] Support About box. Improve app menu handling.
This commit is contained in:
parent
23d7ac0e58
commit
df0969d1c6
@ -11,13 +11,22 @@ import (
|
||||
)
|
||||
|
||||
func (m *windowsApp) showAboutDialog(title string, message string, icon []byte) {
|
||||
panic("implement me")
|
||||
about := newDialogImpl(&MessageDialog{
|
||||
MessageDialogOptions: MessageDialogOptions{
|
||||
DialogType: InfoDialog,
|
||||
Title: title,
|
||||
Message: message,
|
||||
},
|
||||
})
|
||||
about.UseAppIcon = true
|
||||
about.show()
|
||||
}
|
||||
|
||||
type windowsDialog struct {
|
||||
dialog *MessageDialog
|
||||
|
||||
//dialogImpl unsafe.Pointer
|
||||
UseAppIcon bool
|
||||
}
|
||||
|
||||
func (m *windowsDialog) show() {
|
||||
@ -25,8 +34,14 @@ func (m *windowsDialog) show() {
|
||||
title := w32.MustStringToUTF16Ptr(m.dialog.Title)
|
||||
message := w32.MustStringToUTF16Ptr(m.dialog.Message)
|
||||
flags := calculateMessageDialogFlags(m.dialog.MessageDialogOptions)
|
||||
var button int32
|
||||
|
||||
button, _ := windows.MessageBox(windows.HWND(0), message, title, flags|windows.MB_SYSTEMMODAL)
|
||||
if m.UseAppIcon {
|
||||
// 3 is the application icon
|
||||
button, _ = w32.MessageBoxWithIcon(0, message, title, 3, windows.MB_OK|windows.MB_USERICON)
|
||||
} else {
|
||||
button, _ = windows.MessageBox(windows.HWND(0), message, title, flags|windows.MB_SYSTEMMODAL)
|
||||
}
|
||||
// This maps MessageBox return values to strings
|
||||
responses := []string{"", "Ok", "Cancel", "Abort", "Retry", "Ignore", "Yes", "No", "", "", "Try Again", "Continue"}
|
||||
result := "Error"
|
||||
|
@ -54,7 +54,9 @@ func (m *Menu) AddSubmenu(s string) *Menu {
|
||||
|
||||
func (m *Menu) AddRole(role Role) *Menu {
|
||||
result := newRole(role)
|
||||
if result != nil {
|
||||
m.items = append(m.items, result)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
|
@ -186,8 +186,10 @@ func newSelectAllMenuItem() *MenuItem {
|
||||
}
|
||||
|
||||
func newAboutMenuItem() *MenuItem {
|
||||
panic("implement me")
|
||||
|
||||
return newMenuItem("About " + globalApplication.options.Name).
|
||||
OnClick(func(ctx *Context) {
|
||||
globalApplication.ShowAboutDialog()
|
||||
})
|
||||
}
|
||||
|
||||
func newCloseMenuItem() *MenuItem {
|
||||
|
@ -89,6 +89,9 @@ func newViewMenu() *MenuItem {
|
||||
}
|
||||
|
||||
func newAppMenu() *MenuItem {
|
||||
if runtime.GOOS != "darwin" {
|
||||
return nil
|
||||
}
|
||||
appMenu := NewMenu()
|
||||
appMenu.AddRole(About)
|
||||
appMenu.AddSeparator()
|
||||
|
Loading…
Reference in New Issue
Block a user