2
0
mirror of https://github.com/OrbTools/OrbBind synced 2024-11-15 12:13:00 +00:00

Fix keymaps and etc

This commit is contained in:
Mini 2020-05-23 18:24:36 -04:00
parent 7b11ae9382
commit 1a62bc5299
2 changed files with 7 additions and 14 deletions

View File

@ -74,7 +74,7 @@ func CKIFyneKeyMap(e fyne.KeyName) int {
case desktop.KeyShiftRight: case desktop.KeyShiftRight:
return CommonToASCII["KEY_RIGHTSHIFT"] return CommonToASCII["KEY_RIGHTSHIFT"]
default: default:
return 0x0 return int(e[0])
} }
} }

View File

@ -1,8 +1,6 @@
package bind package bind
import ( import (
"strings"
"fyne.io/fyne" "fyne.io/fyne"
"fyne.io/fyne/driver/desktop" "fyne.io/fyne/driver/desktop"
"fyne.io/fyne/layout" "fyne.io/fyne/layout"
@ -27,20 +25,16 @@ type Page struct {
//TypeKey event on key //TypeKey event on key
func (bp *Page) TypeKey(e *fyne.KeyEvent) { 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) 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 { func (bp *Page) createGrid() *fyne.Container {
cont := fyne.NewContainerWithLayout(layout.NewGridLayoutWithColumns(3)) cont := fyne.NewContainerWithLayout(layout.NewGridLayoutWithColumns(3))
cont.AddObject(widget.NewButton("Clear", func() { 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 = make(map[string]fyne.CanvasObject)
bp.dev["BL"] = widget.NewLabel(keys.CKIName(bp.Bind.Bound)) bp.dev["BL"] = widget.NewLabel(keys.CKIName(bp.Bind.Bound))
pop := widget.NewVBox(bp.dev["BL"], bp.createGrid()) pop := widget.NewVBox(bp.dev["BL"], bp.createGrid())
bp.window.Canvas().SetOnTypedRune(bp.TypeRune)
bp.window.Canvas().SetOnTypedKey(bp.TypeKey) bp.window.Canvas().SetOnTypedKey(bp.TypeKey)
return pop return pop
} }