Flex:模拟按键 [英] Flex: Simulate key press

查看:30
本文介绍了Flex:模拟按键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为触摸屏 Flex 应用程序创建一个虚拟键盘,我正在尝试通过调度 KeyboardEvent 来模拟按键操作.我已经编写了一个处理函数来监听事件并采取相应的行动.到目前为止一切顺利......但它开始变得复杂,因为我必须管理聚焦的文本输入(简单),这些字段中的光标位置(不是那么容易)等.现在,如果只有一种方法可以实际调度一个键盘事件,Flex 实际上会将其解释为真正的按键操作,所有这些问题都会消失......这可能吗?

I'm creating a virtual keyboard for a touchscreen Flex app and i'm trying to simulate a key press by dispatching a KeyboardEvent. I've written a handler function to listen for the event and act accordingly. So far so good... but it's starting to get complicated as i have to manage the focused textInputs (easy), the cursor position in those fields (not to so easy), etc. Now, if only there was a way to actually dispatch a KeyboardEvent that Flex would actually interpret as a genuine key press all those issues would be gone... Is that possible?

推荐答案

TextInput 不使用 KeyboardEvent/TextEvent 进行文本输入,它使用与 Flash Player/Keyboard 交互的内部 Flash TextField 对象.

The TextInput does not use KeyboardEvent/TextEvent for text input, it uses internal Flash TextField objects that interact with the Flash Player / Keyboard.

KeyboardEvent 用于启用对发生的键盘事件的通知.

The KeyboardEvent are used to enable notification of the Keyboard Event that occured.

要模拟键盘,您需要创建一个类,该类在收到 KeyboardEvent 时将相应地修改 TextInput 的文本属性和光标位置.

To simulate a keyboard, you will need to create a class that upon recieving a KeyboardEvent will modify the text property of a TextInput and the cursor position accordingly.

Alex Harui 写了一篇关于此FlexCoders Post

Alex Harui has written a similar post about this FlexCoders Post

这篇关于Flex:模拟按键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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