Delphi FMX:如何可靠地检测Android设备上的Return键按下? [英] Delphi FMX: How to reliably detect pressing of Return key on Android device?

查看:357
本文介绍了Delphi FMX:如何可靠地检测Android设备上的Return键按下?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

提供了Delphi 10.1 Berlin更新2 Firemonkey Android应用程序和TEdit.我想检测用户在TEdit中时何时按下Enter键.

given a Delphi 10.1 Berlin update 2 Firemonkey Android app and a TEdit. I like to detect when the user presses Enter while being in the TEdit.

我已经实现了OnTyping事件,在其中循环遍历.Text属性的所有字符. 如果检测到vkLineFeed或vkReturn,则输入Enter(我发现某些设备确实发送了该设备而不是vkReturn,从而添加了对vkLineFeed的检查).

I implemented an OnTyping event already where I loop through all the chars of the .Text property. If vkLineFeed or vkReturn is detected it is Enter (I added the check for vkLineFeed by finding out that certain devices do send that one instead of vkReturn).

ReturnKeyType是默认值.当被设置为完成或执行时,看起来我什至都没有获得Enter键才能在.Text中看到. TEdit的OnKeyDown/OnKeyUp事件不会在Android上的FMX应用中故意触发.

ReturnKeyType is default. When being set to done or go it looks like I don't even get the Enter key to see in .Text. The OnKeyDown/OnKeyUp events of a TEdit do not fire on purpose in a FMX app on Android.

但是现在我遇到了一个设备,该设备只是在Enter时关闭键盘,却没有向我发送任何输入"字符.这是搭载Android 4.4的LG L50.

But now I encountered a device which simply closes the keyboard on enter but doesn't send me any "enter" char. It's a LG L50 with Android 4.4.

是否有某种方法可以可靠地检测Android/FMX上的回车压力?

Is there some method to reliably detect return presses on Android/FMX?

推荐答案

这是一个可行的解决方案: http://www.danielespinetti.it/2017/03/intercept-keyevent-on-android-with.html

Here is a working solution: http://www.danielespinetti.it/2017/03/intercept-keyevent-on-android-with.html

我在尝试备忘录时遇到问题,但是在将TEdit添加到表单并对其进行了测试(因为无论如何我都想使用TEdit)后,它就可以在LG L50上使用了.需要在其他设备上进行进一步的测试,但由于那是无法正常工作的设备...

I had issues with the memo when trying it out, but after I added a TEdit to the form and tested with that one (as I wanted to use a TEdit anyhow) it worked on the LG L50. Further tests on other devices need to be carried out, but since that was the not functioning device...

有趣的是,用于显示打开的应用程序列表(最右边的一个)的硬件密钥被检测为0x12.

Interestingly the hardware key used to show the list of open apps (the most right one) was detected as 0x12.

这篇关于Delphi FMX:如何可靠地检测Android设备上的Return键按下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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