微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

JavaFX And​​roid 应用程序使用 client-maven-plugin / GraalVM 和 BACK 事件

如何解决JavaFX And​​roid 应用程序使用 client-maven-plugin / GraalVM 和 BACK 事件

我设法使用 gluon 的 client-maven-plugin 为 Android 创建了 JavaFX 应用程序。 到目前为止一切都很好,但我没有设法对 Android 上的本机 BACK 导航做出反应。我尝试向场景中添加键事件侦听器 - 在桌面上工作并允许对按下的 ESC 键做出反应,但在 Android 上甚至没有调用事件处理程序。

我看到,事件本身到达了 GraalVM,看起来它被解释为按下并释放的 BACK 键:

02-17 20:46:52.937  8275  8275 V GraalActivity: Activity,process get key event,action = 0
02-17 20:46:52.937  8275  8275 I System.out: KeyEvent: KeyEvent { action=ACTION_DOWN,keyCode=KEYCODE_BACK,scanCode=0,MetaState=0,flags=0x48,repeatCount=0,eventTime=244804749,downTime=244804749,deviceid=-1,source=0x101,displayId=0 } with action = 0
02-17 20:46:52.937  8275  8275 I System.out: [JVDBG] eventkeycode = 4 and jfxkc = ESCAPE with code 27
02-17 20:46:52.937  8275  8275 E Graalgluon: Native Dalvik layer has to dispatch key event,pass to native Graal layer with 1 chars...
02-17 20:46:52.937  8275  8275 E Graalgluon: passed count = 1 and realcount = 1
02-17 20:46:52.937  8275  8275 E Graalgluon: c0 = nd c1 = s
02-17 20:46:52.937  8275  8275 E Graalgluon: c0 = 1b and c1 = 7473
02-17 20:46:53.003  8275  8275 V GraalActivity: Activity,action = 1
02-17 20:46:53.003  8275  8275 I System.out: KeyEvent: KeyEvent { action=ACTION_UP,eventTime=244804818,displayId=0 } with action = 1
02-17 20:46:53.003  8275  8275 E Graalgluon: Native Dalvik layer has to dispatch key event,pass to native Graal layer with 1 chars...
02-17 20:46:53.003  8275  8275 E Graalgluon: passed count = 1 and realcount = 1
02-17 20:46:53.003  8275  8275 E Graalgluon: c0 = nd c1 = s
02-17 20:46:53.003  8275  8275 E Graalgluon: c0 = 1b and c1 = 7473

我当前尝试捕获该键盘输入

scene.setonKeypressed(ev -> {
    System.out.println("onKeypressed: "+ev.getCode() +" bzw. "+ev.getCharacter());
});

但从日志来看,它从未被调用过。

那么:我需要做什么来处理这个事件?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。