~eliasnaur/gio-patches

fix handling of enter key for android v1 PROPOSED

: 1
 fix handling of enter key for android

 1 files changed, 5 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~eliasnaur/gio-patches/patches/11783/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] fix handling of enter key for android Export this patch

From: David Linus Briemann <dlb@mailbox.org>

- add proper keycode for android enter key event
- test if a character is printable via unicode pkg from go std lib
---
 app/internal/window/os_android.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/app/internal/window/os_android.go b/app/internal/window/os_android.go
index 3458b26..1beb79b 100644
--- a/app/internal/window/os_android.go
+++ b/app/internal/window/os_android.go
@@ -48,6 +48,7 @@ import (
	"runtime/debug"
	"sync"
	"time"
	"unicode"
	"unicode/utf16"
	"unsafe"

@@ -442,6 +443,8 @@ func convertKeyCode(code C.jint) (string, bool) {
		n = key.NameDeleteForward
	case C.AKEYCODE_DEL:
		n = key.NameDeleteBackward
	case C.AKEYCODE_ENTER:
		n = key.NameEnter
	default:
		return "", false
	}
@@ -454,7 +457,8 @@ func Java_org_gioui_GioView_onKeyEvent(env *C.JNIEnv, class C.jclass, handle C.j
	if n, ok := convertKeyCode(keyCode); ok {
		w.callbacks.Event(key.Event{Name: n})
	}
	if r != 0 {
	char := rune(r)
	if unicode.IsPrint(char) {
		w.callbacks.Event(key.EditEvent{Text: string(rune(r))})
	}
}
-- 
2.25.1
LGTM. One comment below.

On Wed Jul 29, 2020 at 17:39,  wrote: