gpt4 book ai didi

android - AIR/as3 阶段 keylistener 覆盖输入文本字段

转载 作者:塔克拉玛干 更新时间:2023-11-02 10:11:01 25 4
gpt4 key购买 nike

我正在使用 Adob​​e Flash Builder 4.6 构建移动 AIR 应用程序(Android 和 IOS),但我遇到了这个恼人的问题。

因为我想在 Android 设备上“捕获”后退键,所以我将以下代码添加到我的主类中:

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);

private function keyDown(k:KeyboardEvent):void {
if(k.keyCode == Keyboard.BACK) {
backClicked(); // function handling the back-action, not important
k.preventDefault();
}

现在在其他地方 - 嵌套在一些类中 - 我有一个文本字段:

TF = new TextField();
TF.type = TextFieldType.INPUT;

但是当我将焦点放在文本字段上时,软键盘会出现,但我无法输入单个字符。当我禁用 keylistener 时:没问题。

听众似乎覆盖了我的输入字段。有什么解决方法吗?

最佳答案

我也为我的移动应用程序实现了后退按钮功能,但我过去只在我的特定 View 被激活时注册按键事件,并在 View 被停用时删除注册。

in <s:view ....... viewActivate ="enableHardwareKeyListeners(event)" viewDeactivate="destroyHardwareKeyListeners(event)">
// add listener only for android device
if (Check for android device) {
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleHardwareKeysDown, false, 0);
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_UP, handleHardwareKeysUp, false, 0);
this.setFocus();
}


private function destroyHardwareKeyListeners(event:ViewNavigatorEvent):void
{
if (NativeApplication.nativeApplication.hasEventListener(KeyboardEvent.KEY_DOWN))
NativeApplication.nativeApplication.removeEventListener(KeyboardEvent.KEY_DOWN, handleHardwareKeysDown);
if (NativeApplication.nativeApplication.hasEventListener(KeyboardEvent.KEY_UP))
NativeApplication.nativeApplication.removeEventListener(KeyboardEvent.KEY_UP, handleHardwareKeysUp);
}

private function handleHardwareKeysDown(e:KeyboardEvent):void
{
if (e.keyCode == Keyboard.BACK) {
e.preventDefault();
// your code
} else {

}
}

private function handleHardwareKeysUp(e:KeyboardEvent):void
{
if (e.keyCode == Keyboard.BACK)
e.preventDefault();
}

希望这对你有帮助。

关于android - AIR/as3 阶段 keylistener 覆盖输入文本字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15549669/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com