Delphi Android 10.3.3上的Return键没有OnKeyDown事件 [英] No OnKeyDown event for Return key on Delphi Android 10.3.3

查看:126
本文介绍了Delphi Android 10.3.3上的Return键没有OnKeyDown事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从Delphi 10.2.3升级到10.3.3的过程中.我的Android应用程序现在无法从虚拟键盘为Return键生成OnKeyDown事件.我已经使用一个非常基本的新创建的项目确认了这一点,因此它似乎与从10.2.3进行的转换无关.

I am in the process of upgrading from Delphi 10.2.3 to 10.3.3. My android apps are now not generating an OnKeyDown event from the virtual keyboard for the Return key. I have confirmed this using a very basic newly created project so it is nothing to do with the conversion from 10.2.3 it seems.

任何想法都会受到赞赏.

Any ideas would be appreciated.

embarcadero的质量检查人员返回了以下回复:

QA at embarcadero have come back with the following response:

根据本文档-处理键盘操作或此- KeyEvent :

在使用KeyEvent类和相关API处理键盘事件时,您应该期望此类键盘事件仅来自硬件键盘.您不应该依靠软输入法(屏幕键盘)上的任何键来接收键事件.

When handling keyboard events with the KeyEvent class and related APIs, you should expect that such keyboard events come only from a hardware keyboard. You should never rely on receiving key events for any key on a soft input method (an on-screen keyboard).

我认为使用更改文本时启动的方法可以解决此问题...

I think that using methods that fire up when text get changed is a sufficient workaround to this issue...

我认为这Stackoverflow 问题和此博客可能会有用."

I think this Stackoverflow question and this Blogpost may be useful. "

提供的解决方案涉及将文本侦听器添加到JFMXTextEditorProxy,而后者的接口已从delphi 10.3中消失.我目前正在尝试实现10.3中的等效功能,但不胜感激.顺便说一句:其他人会有不同的目标,但就我而言,我只想看到返回键.

The solution offered involves adding a TextListener to JFMXTextEditorProxy, and that latter interface has disappeared from delphi 10.3. I am currently attempting to implement something equivalent in 10.3, but would appreciate any guidance. BTW: Others will have different aims, but for my part all I want to see is the return key.

推荐答案

更新:最初假定它是一个错误.然而,embarcadero的质量检查人员认为不是,并且不应该依赖虚拟键盘触发键盘事件.但是他们没有其他可行的选择.他们引用的博客文章不适用于10.3,而且似乎永远也看不到返回键.

Update: Originally this was assumed to be a bug. QA at embarcadero however take the view that it is not and one should not rely on the virtual keyboard to fire off keyboard events. But they offer no other viable alternatives. The blog post they cited is not suitable for 10.3, and it seems that it would never see the return key anyway.

我偶然发现了一个可行的解决方法,尽管它也可能会受到将来更改的影响.

I have stumbled across a workaround, which appears to work, though it too may be susceptible to future changes.

如果将Tedit的ReturnKeyType更改为任何值 Go Search Send ,则onkeydown事件将触发返回键.另一种选择是使用OnChange事件.当Tedit设置为Default ReturnKeyType时,这都不为返回键触发,但是当设置为上述任何值(也加上Next)时,它将触发.ReturnKeyType在设计时可用,也可以在代码中进行更改,例如:

If one changes the ReturnKeyType of a Tedit to any of the values Go, Search or Send, the onkeydown event will fire for the return key. Another alternative would be to use the OnChange event. This does not fire for the return key, when the Tedit is set to Default ReturnKeyType either, but when set to any of the above values (plus Next also), it will fire. ReturnKeyType is available at design time, and can also be changed in code e.g.:

  edit1.ReturnKeyType := TReturnKeyType.Go;

如果真的很绝望,我观察到,如果确实更改了编辑的内容并且使用Android的后退"按钮关闭虚拟键盘,则会触发OnChange事件.

And if really desperate, I have observed that the OnChange event will fire if the contents of the edit have indeed changed and one uses the Android "back" button to dismiss the virtual keyboard.

这篇关于Delphi Android 10.3.3上的Return键没有OnKeyDown事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆