diff --git a/v3/examples/keybindings/main.go b/v3/examples/keybindings/main.go index 15a93bc9c..a78068ac2 100644 --- a/v3/examples/keybindings/main.go +++ b/v3/examples/keybindings/main.go @@ -4,7 +4,6 @@ import ( _ "embed" "github.com/wailsapp/wails/v3/pkg/application" "log" - "log/slog" ) func main() { @@ -15,11 +14,10 @@ func main() { ApplicationShouldTerminateAfterLastWindowClosed: true, }, KeyBindings: map[string]func(window *application.WebviewWindow){ - "F11": func(window *application.WebviewWindow) { + "shift+ctrl+c": func(window *application.WebviewWindow) { window.Center() }, }, - LogLevel: slog.LevelDebug, }) app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{ diff --git a/v3/pkg/application/bindings.go b/v3/pkg/application/bindings.go index 5dd2b47b7..21f763450 100644 --- a/v3/pkg/application/bindings.go +++ b/v3/pkg/application/bindings.go @@ -152,7 +152,7 @@ func (b *Bindings) AddPlugins(plugins map[string]Plugin) error { } b.boundMethods[packageName][structName][methodName] = method b.boundByID[method.ID] = method - globalApplication.info("Added plugin method: "+structName+"."+methodName, "id", method.ID) + globalApplication.debug("Added plugin method: "+structName+"."+methodName, "id", method.ID) } } return nil @@ -265,7 +265,7 @@ func (b *Bindings) getMethods(value interface{}, isPlugin bool) ([]*BoundMethod, args = append(args, "alias", alias) } } - globalApplication.info("Adding method:", args...) + globalApplication.debug("Adding method:", args...) } // Iterate inputs methodType := method.Type() diff --git a/v3/pkg/application/keys.go b/v3/pkg/application/keys.go index 5afa7e87e..4a6fc0e64 100644 --- a/v3/pkg/application/keys.go +++ b/v3/pkg/application/keys.go @@ -71,15 +71,16 @@ type accelerator struct { } func (a *accelerator) String() string { - result := strings.Builder{} + var result []string // Sort modifiers - slices.Sort(a.Modifiers) for _, modifier := range a.Modifiers { - result.WriteString(modifier.String()) - result.WriteString("+") + result = append(result, modifier.String()) } - result.WriteString(a.Key) - return strings.ToLower(result.String()) + slices.Sort(result) + if len(a.Key) > 0 { + result = append(result, a.Key) + } + return strings.ToLower(strings.Join(result, "+")) } var namedKeys = map[string]struct{}{ diff --git a/v3/pkg/application/keys_windows.go b/v3/pkg/application/keys_windows.go index a6a2a1f4a..8011a837d 100644 --- a/v3/pkg/application/keys_windows.go +++ b/v3/pkg/application/keys_windows.go @@ -14,7 +14,7 @@ var VirtualKeyCodes = map[uint]string{ 0x0C: "clear", 0x0D: "return", 0x10: "shift", - 0x11: "control", + 0x11: "ctrl", 0x12: "menu", 0x13: "pause", 0x14: "capital", diff --git a/v3/pkg/application/plugins.go b/v3/pkg/application/plugins.go index 26b8b5615..423ce2ac2 100644 --- a/v3/pkg/application/plugins.go +++ b/v3/pkg/application/plugins.go @@ -37,7 +37,7 @@ func (p *PluginManager) Init() error { if injectJS != "" { p.assetServer.AddPluginScript(plugin.Name(), injectJS) } - globalApplication.info("Plugin initialised: " + plugin.Name()) + globalApplication.debug("Plugin initialised: " + plugin.Name()) } return nil } @@ -45,6 +45,6 @@ func (p *PluginManager) Init() error { func (p *PluginManager) Shutdown() { for _, plugin := range p.initialisedPlugins { plugin.Shutdown() - globalApplication.info("Plugin shutdown: " + plugin.Name()) + globalApplication.debug("Plugin shutdown: " + plugin.Name()) } } diff --git a/v3/pkg/application/systemtray_windows.go b/v3/pkg/application/systemtray_windows.go index a7a40b355..0915035c0 100644 --- a/v3/pkg/application/systemtray_windows.go +++ b/v3/pkg/application/systemtray_windows.go @@ -182,7 +182,7 @@ func (s *windowsSystemTray) run() { // Set Default Callbacks if s.parent.clickHandler == nil { s.parent.clickHandler = func() { - globalApplication.info("Left Button Clicked") + globalApplication.debug("Left Button Clicked") } } if s.parent.rightClickHandler == nil { @@ -347,6 +347,6 @@ func (s *windowsSystemTray) destroy() { // Destroy the notification icon nid := s.newNotifyIconData() if !w32.ShellNotifyIcon(w32.NIM_DELETE, &nid) { - globalApplication.info(syscall.GetLastError().Error()) + globalApplication.debug(syscall.GetLastError().Error()) } } diff --git a/v3/pkg/application/webview_window.go b/v3/pkg/application/webview_window.go index d37655338..800bc493d 100644 --- a/v3/pkg/application/webview_window.go +++ b/v3/pkg/application/webview_window.go @@ -217,7 +217,7 @@ func processKeyBindingOptions(keyBindings map[string]func(window *WebviewWindow) continue } result[acc.String()] = callback - globalApplication.info("Added Keybinding", "accelerator", acc.String()) + globalApplication.debug("Added Keybinding", "accelerator", acc.String()) } return result } diff --git a/v3/pkg/application/webview_window_darwin.go b/v3/pkg/application/webview_window_darwin.go index 51a3f7f50..3d50821af 100644 --- a/v3/pkg/application/webview_window_darwin.go +++ b/v3/pkg/application/webview_window_darwin.go @@ -888,12 +888,12 @@ func (w *macosWebviewWindow) toggleDevTools() { func (w *macosWebviewWindow) reload() { //TODO: Implement - globalApplication.info("reload called on WebviewWindow", "parentID", w.parent.id) + globalApplication.debug("reload called on WebviewWindow", "parentID", w.parent.id) } func (w *macosWebviewWindow) forceReload() { //TODO: Implement - globalApplication.info("force reload called on WebviewWindow", "parentID", w.parent.id) + globalApplication.debug("force reload called on WebviewWindow", "parentID", w.parent.id) } func (w *macosWebviewWindow) center() { diff --git a/v3/pkg/application/webview_window_windows.go b/v3/pkg/application/webview_window_windows.go index db3c10711..9dad61c9a 100644 --- a/v3/pkg/application/webview_window_windows.go +++ b/v3/pkg/application/webview_window_windows.go @@ -1469,14 +1469,15 @@ func (w *windowsWebviewWindow) processKeyBinding(vkey uint) bool { acc.Modifiers = append(acc.Modifiers, SuperKey) } - // Convert the vkey to a string - accKey, ok := VirtualKeyCodes[vkey] - if !ok { - return false + if vkey != w32.VK_CONTROL && vkey != w32.VK_MENU && vkey != w32.VK_SHIFT && vkey != w32.VK_LWIN && vkey != w32.VK_RWIN { + // Convert the vkey to a string + accKey, ok := VirtualKeyCodes[vkey] + if !ok { + return false + } + acc.Key = accKey } - acc.Key = accKey - // Process the key binding return w.parent.processKeyBinding(acc.String())