问题描述
我设法使用 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 (将#修改为@)