mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
[windows] Misc updates for feature parity
This commit is contained in:
parent
52554009ce
commit
817952f3d0
8 changed files with 73 additions and 73 deletions
|
|
@ -64,9 +64,9 @@ func processMenuItem(parent *winc.MenuItem, menuItem *menu.MenuItem) {
|
|||
case menu.TextType:
|
||||
shortcut := acceleratorToWincShortcut(menuItem.Accelerator)
|
||||
newItem := parent.AddItem(menuItem.Label, shortcut)
|
||||
if menuItem.Tooltip != "" {
|
||||
newItem.SetToolTip(menuItem.Tooltip)
|
||||
}
|
||||
//if menuItem.Tooltip != "" {
|
||||
// newItem.SetToolTip(menuItem.Tooltip)
|
||||
//}
|
||||
if menuItem.Click != nil {
|
||||
newItem.OnClick().Bind(func(e *winc.Event) {
|
||||
menuItem.Click(&menu.CallbackData{
|
||||
|
|
@ -81,9 +81,9 @@ func processMenuItem(parent *winc.MenuItem, menuItem *menu.MenuItem) {
|
|||
newItem := parent.AddItem(menuItem.Label, shortcut)
|
||||
newItem.SetCheckable(true)
|
||||
newItem.SetChecked(menuItem.Checked)
|
||||
if menuItem.Tooltip != "" {
|
||||
newItem.SetToolTip(menuItem.Tooltip)
|
||||
}
|
||||
//if menuItem.Tooltip != "" {
|
||||
// newItem.SetToolTip(menuItem.Tooltip)
|
||||
//}
|
||||
if menuItem.Click != nil {
|
||||
newItem.OnClick().Bind(func(e *winc.Event) {
|
||||
toggleCheckBox(menuItem)
|
||||
|
|
@ -99,9 +99,9 @@ func processMenuItem(parent *winc.MenuItem, menuItem *menu.MenuItem) {
|
|||
newItem := parent.AddItemRadio(menuItem.Label, shortcut)
|
||||
newItem.SetCheckable(true)
|
||||
newItem.SetChecked(menuItem.Checked)
|
||||
if menuItem.Tooltip != "" {
|
||||
newItem.SetToolTip(menuItem.Tooltip)
|
||||
}
|
||||
//if menuItem.Tooltip != "" {
|
||||
// newItem.SetToolTip(menuItem.Tooltip)
|
||||
//}
|
||||
if menuItem.Click != nil {
|
||||
newItem.OnClick().Bind(func(e *winc.Event) {
|
||||
toggleRadioItem(menuItem)
|
||||
|
|
|
|||
|
|
@ -92,8 +92,8 @@ func (m *Manager) ProcessClick(menuID string, data string, menuType string, pare
|
|||
|
||||
// Create new Callback struct
|
||||
callbackData := &menu.CallbackData{
|
||||
MenuItem: menuItem,
|
||||
ContextData: data,
|
||||
MenuItem: menuItem,
|
||||
//ContextData: data,
|
||||
}
|
||||
|
||||
// Call back!
|
||||
|
|
|
|||
|
|
@ -2,10 +2,6 @@ package menumanager
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/leaanthony/go-ansi-parser"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||
"github.com/wailsapp/wails/v2/pkg/menu/keys"
|
||||
)
|
||||
|
|
@ -15,7 +11,7 @@ type ProcessedMenuItem struct {
|
|||
// Label is what appears as the menu text
|
||||
Label string `json:",omitempty"`
|
||||
// Role is a predefined menu type
|
||||
Role menu.Role `json:",omitempty"`
|
||||
//Role menu.Role `json:",omitempty"`
|
||||
// Accelerator holds a representation of a key binding
|
||||
Accelerator *keys.Accelerator `json:",omitempty"`
|
||||
// Type of MenuItem, EG: Checkbox, Text, Separator, Radio, Submenu
|
||||
|
|
@ -29,24 +25,25 @@ type ProcessedMenuItem struct {
|
|||
// Submenu contains a list of menu items that will be shown as a submenu
|
||||
//SubMenu []*MenuItem `json:"SubMenu,omitempty"`
|
||||
SubMenu *ProcessedMenu `json:",omitempty"`
|
||||
/*
|
||||
// Colour
|
||||
RGBA string `json:",omitempty"`
|
||||
|
||||
// Colour
|
||||
RGBA string `json:",omitempty"`
|
||||
// Font
|
||||
FontSize int `json:",omitempty"`
|
||||
FontName string `json:",omitempty"`
|
||||
|
||||
// Font
|
||||
FontSize int `json:",omitempty"`
|
||||
FontName string `json:",omitempty"`
|
||||
// Image - base64 image data
|
||||
Image string `json:",omitempty"`
|
||||
MacTemplateImage bool `json:", omitempty"`
|
||||
MacAlternate bool `json:", omitempty"`
|
||||
|
||||
// Image - base64 image data
|
||||
Image string `json:",omitempty"`
|
||||
MacTemplateImage bool `json:", omitempty"`
|
||||
MacAlternate bool `json:", omitempty"`
|
||||
// Tooltip
|
||||
Tooltip string `json:",omitempty"`
|
||||
|
||||
// Tooltip
|
||||
Tooltip string `json:",omitempty"`
|
||||
|
||||
// Styled label
|
||||
StyledLabel []*ansi.StyledText `json:",omitempty"`
|
||||
// Styled label
|
||||
StyledLabel []*ansi.StyledText `json:",omitempty"`
|
||||
*/
|
||||
}
|
||||
|
||||
func NewProcessedMenuItem(menuItemMap *MenuItemMap, menuItem *menu.MenuItem) *ProcessedMenuItem {
|
||||
|
|
@ -54,33 +51,33 @@ func NewProcessedMenuItem(menuItemMap *MenuItemMap, menuItem *menu.MenuItem) *Pr
|
|||
ID := menuItemMap.menuItemToIDMap[menuItem]
|
||||
|
||||
// Parse ANSI text
|
||||
var styledLabel []*ansi.StyledText
|
||||
tempLabel := menuItem.Label
|
||||
if strings.Contains(tempLabel, "\033[") {
|
||||
parsedLabel, err := ansi.Parse(menuItem.Label)
|
||||
if err == nil {
|
||||
styledLabel = parsedLabel
|
||||
}
|
||||
}
|
||||
//var styledLabel []*ansi.StyledText
|
||||
//tempLabel := menuItem.Label
|
||||
//if strings.Contains(tempLabel, "\033[") {
|
||||
// parsedLabel, err := ansi.Parse(menuItem.Label)
|
||||
// if err == nil {
|
||||
// styledLabel = parsedLabel
|
||||
// }
|
||||
//}
|
||||
|
||||
result := &ProcessedMenuItem{
|
||||
ID: ID,
|
||||
Label: menuItem.Label,
|
||||
Role: menuItem.Role,
|
||||
Accelerator: menuItem.Accelerator,
|
||||
Type: menuItem.Type,
|
||||
Disabled: menuItem.Disabled,
|
||||
Hidden: menuItem.Hidden,
|
||||
Checked: menuItem.Checked,
|
||||
SubMenu: nil,
|
||||
RGBA: menuItem.RGBA,
|
||||
FontSize: menuItem.FontSize,
|
||||
FontName: menuItem.FontName,
|
||||
Image: menuItem.Image,
|
||||
MacTemplateImage: menuItem.MacTemplateImage,
|
||||
MacAlternate: menuItem.MacAlternate,
|
||||
Tooltip: menuItem.Tooltip,
|
||||
StyledLabel: styledLabel,
|
||||
ID: ID,
|
||||
Label: menuItem.Label,
|
||||
//Role: menuItem.Role,
|
||||
Accelerator: menuItem.Accelerator,
|
||||
Type: menuItem.Type,
|
||||
Disabled: menuItem.Disabled,
|
||||
Hidden: menuItem.Hidden,
|
||||
Checked: menuItem.Checked,
|
||||
SubMenu: nil,
|
||||
//RGBA: menuItem.RGBA,
|
||||
//FontSize: menuItem.FontSize,
|
||||
//FontName: menuItem.FontName,
|
||||
//Image: menuItem.Image,
|
||||
//MacTemplateImage: menuItem.MacTemplateImage,
|
||||
//MacAlternate: menuItem.MacAlternate,
|
||||
//Tooltip: menuItem.Tooltip,
|
||||
//StyledLabel: styledLabel,
|
||||
}
|
||||
|
||||
if menuItem.SubMenu != nil {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func generateIcoFile(options *Options) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = winicon.GenerateIcon(input, output, []int{512, 256, 128, 64, 48, 32, 16})
|
||||
err = winicon.GenerateIcon(input, output, []int{256, 128, 64, 48, 32, 16})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ func TestParse(t *testing.T) {
|
|||
{"CTRL+plus", Control("+")},
|
||||
{"CTRL+SHIFT+escApe", Combo("escape", ControlKey, ShiftKey)},
|
||||
{";", Key(";")},
|
||||
{"Super+Tab", Super("tab")},
|
||||
{"OptionOrAlt+Page Down", OptionOrAlt("Page Down")},
|
||||
}
|
||||
for _, tt := range gooddata {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ type MenuItem struct {
|
|||
// Label is what appears as the menu text
|
||||
Label string
|
||||
// Role is a predefined menu type
|
||||
Role Role `json:"Role,omitempty"`
|
||||
//Role Role `json:"Role,omitempty"`
|
||||
// Accelerator holds a representation of a key binding
|
||||
Accelerator *keys.Accelerator `json:"Accelerator,omitempty"`
|
||||
// Type of MenuItem, EG: Checkbox, Text, Separator, Radio, Submenu
|
||||
|
|
@ -28,26 +28,26 @@ type MenuItem struct {
|
|||
|
||||
// Callback function when menu clicked
|
||||
Click Callback `json:"-"`
|
||||
/*
|
||||
// Text Colour
|
||||
RGBA string
|
||||
|
||||
// Text Colour
|
||||
RGBA string
|
||||
// Font
|
||||
FontSize int
|
||||
FontName string
|
||||
|
||||
// Font
|
||||
FontSize int
|
||||
FontName string
|
||||
// Image - base64 image data
|
||||
Image string
|
||||
|
||||
// Image - base64 image data
|
||||
Image string
|
||||
// MacTemplateImage indicates that on a Mac, this image is a template image
|
||||
MacTemplateImage bool
|
||||
|
||||
// MacTemplateImage indicates that on a Mac, this image is a template image
|
||||
MacTemplateImage bool
|
||||
|
||||
// MacAlternate indicates that this item is an alternative to the previous menu item
|
||||
MacAlternate bool
|
||||
|
||||
// Tooltip
|
||||
Tooltip string
|
||||
// MacAlternate indicates that this item is an alternative to the previous menu item
|
||||
MacAlternate bool
|
||||
|
||||
// Tooltip
|
||||
Tooltip string
|
||||
*/
|
||||
// This holds the menu item's parent.
|
||||
parent *MenuItem
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
// Electron License: https://github.com/electron/electron/blob/master/LICENSE
|
||||
package menu
|
||||
|
||||
/*
|
||||
type Role string
|
||||
|
||||
const (
|
||||
|
|
@ -202,3 +203,4 @@ func HelpSubMenu() *MenuItem {
|
|||
Role: HelpSubMenuRole,
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package menu
|
||||
|
||||
/*
|
||||
// DefaultWindowsMenu returns a default menu including the default
|
||||
// Application and Edit menus. Use `.Append()` to add to it.
|
||||
func DefaultWindowsMenu() *Menu {
|
||||
|
|
@ -9,3 +10,4 @@ func DefaultWindowsMenu() *Menu {
|
|||
WindowMenu(),
|
||||
)
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue