app,io/key,io/system: [API] replace system.CommandEvent with key.Event

It's much simpler to map the Android back button to a key.Event and
let the usual key filtering determine whether to block its default
behaviour.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-04-14 17:45:04 +02:00
parent ad7c1eb78d
commit 6c76fa6dec
5 changed files with 20 additions and 37 deletions
+1 -3
View File
@@ -571,9 +571,7 @@ func Java_org_gioui_GioView_onFrameCallback(env *C.JNIEnv, class C.jclass, view
//export Java_org_gioui_GioView_onBack
func Java_org_gioui_GioView_onBack(env *C.JNIEnv, class C.jclass, view C.jlong) C.jboolean {
w := cgo.Handle(view).Value().(*window)
ev := &system.CommandEvent{Type: system.CommandBack}
w.callbacks.Event(ev)
if ev.Cancel {
if w.callbacks.Event(key.Event{Name: key.NameBack}) {
return C.JNI_TRUE
}
return C.JNI_FALSE