Fix modifier processing on windows.

Move info logs to debug.
This commit is contained in:
Lea Anthony 2023-10-15 13:53:31 +11:00
commit 7795a2a46f
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405
9 changed files with 25 additions and 25 deletions

View file

@ -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{

View file

@ -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()

View file

@ -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{}{

View file

@ -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",

View file

@ -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())
}
}

View file

@ -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())
}
}

View file

@ -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
}

View file

@ -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() {

View file

@ -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())