5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-21 11:29:29 +08:00

Merge pull request #807 from Baiyuetribe/v2-alpha

Add commonly used shortcut keys
This commit is contained in:
Lea Anthony 2021-09-15 23:33:48 +10:00 committed by GitHub
commit 52554009ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,12 +6,13 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/leaanthony/slicer"
"log"
"runtime"
"strconv"
"strings"
"github.com/leaanthony/slicer"
"github.com/leaanthony/go-webview2/pkg/edge"
"github.com/leaanthony/winc"
"github.com/leaanthony/winc/w32"
@ -241,11 +242,16 @@ func (f *Frontend) Quit() {
}
const (
ctrlA int = 65
ctrlZ int = 90
ctrlX = 88
ctrlC = 67
ctrlV = 86
ctrlX = 88
ctrlZ = 90
ctrlA = 65
arrowUp = 38
arrowDown = 40
arrowRight = 39
arrowLeft = 37
keyDel = 46
)
func (f *Frontend) setupChromium() {
@ -254,7 +260,8 @@ func (f *Frontend) setupChromium() {
chromium.MessageCallback = f.processMessage
chromium.WebResourceRequestedCallback = f.processRequest
chromium.NavigationCompletedCallback = f.navigationCompleted
acceleratorsWebviewShouldProcess := slicer.Int([]int{ctrlV, ctrlC, ctrlX, ctrlZ, ctrlA})
acceleratorsWebviewShouldProcess := slicer.Int([]int{ctrlV, ctrlC, ctrlX, ctrlZ, ctrlA, arrowLeft, arrowRight, arrowUp, arrowDown, keyDel})
chromium.AcceleratorKeyCallback = func(vkey uint) bool {
// We want webview to handle ctrl-C, ctrl-Z, ctrl-v, ctrl-x
if acceleratorsWebviewShouldProcess.Contains(int(vkey)) {