From 1d316a11d1f843025e837592c108b77ef719449c Mon Sep 17 00:00:00 2001 From: Minizbot2012 Date: Sat, 23 May 2020 18:24:36 -0400 Subject: [PATCH] Fix keymaps and etc --- keys/cki.go | 2 +- ui/bind/popup.go | 19 ++++++------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/keys/cki.go b/keys/cki.go index c773198..eb0caa6 100644 --- a/keys/cki.go +++ b/keys/cki.go @@ -74,7 +74,7 @@ func CKIFyneKeyMap(e fyne.KeyName) int { case desktop.KeyShiftRight: return CommonToASCII["KEY_RIGHTSHIFT"] default: - return 0x0 + return int(e[0]) } } diff --git a/ui/bind/popup.go b/ui/bind/popup.go index 3462746..bffcb4c 100644 --- a/ui/bind/popup.go +++ b/ui/bind/popup.go @@ -1,8 +1,6 @@ package bind import ( - "strings" - "fyne.io/fyne" "fyne.io/fyne/driver/desktop" "fyne.io/fyne/layout" @@ -27,20 +25,16 @@ type Page struct { //TypeKey event on key func (bp *Page) TypeKey(e *fyne.KeyEvent) { - if keys.CKIDetControl(e.Name) { - kp := keys.CKIDetName(e.Name) - bp.Bind.Bound = keys.CKIFyneKeyMap(e.Name) + bp.Bind.Bound = keys.CKIFyneKeyMap(e.Name) + if !keys.CKIDetControl(e.Name) { + kp := keys.ASCIIToCommon[int(e.Name[0])] + bp.dev["BL"].(*widget.Label).SetText(kp) + } else { + kp := string(e.Name) bp.dev["BL"].(*widget.Label).SetText(kp) } } -//TypeRune event one rune type -func (bp *Page) TypeRune(key rune) { - kp := int(string(strings.ToUpper(string(key)))[0]) - bp.Bind.Bound = kp - bp.dev["BL"].(*widget.Label).SetText(keys.CKIName(bp.Bind.Bound)) -} - func (bp *Page) createGrid() *fyne.Container { cont := fyne.NewContainerWithLayout(layout.NewGridLayoutWithColumns(3)) cont.AddObject(widget.NewButton("Clear", func() { @@ -69,7 +63,6 @@ func (bp *Page) Create(bid string) fyne.CanvasObject { bp.dev = make(map[string]fyne.CanvasObject) bp.dev["BL"] = widget.NewLabel(keys.CKIName(bp.Bind.Bound)) pop := widget.NewVBox(bp.dev["BL"], bp.createGrid()) - bp.window.Canvas().SetOnTypedRune(bp.TypeRune) bp.window.Canvas().SetOnTypedKey(bp.TypeKey) return pop }