模拟按下 Flex 的 Tab 键? [英] Simulate Tab Key Pressed on Flex?

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

问题描述

是否可以在按下另一个键时模拟 Tab 键?我希望做完全相同的事情,但是使用 DOWN &回车键.

It is possible to Simulate a Tab Key when another key is pressed? I'm looking to do exactly the same, but with the DOWN & ENTER Key.

我知道 onKeyDown 函数.我正在尝试这个,但它不起作用.

I know about the onKeyDown function. I'm trying this but it doesn't work.

private function onKeyDown( e:KeyboardEvent ) :void
            {
                if( e.keyCode == Keyboard.DOWN )
                {
                    (e.currentTarget as TextInput).dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY_DOWN, true, false, 0, Keyboard.TAB));
                }
            }

我知道选项卡的工作方式不同,我在这里看到了它,但仍然不知道.

I know tab works differently, I saw it in Here but still not idea.

任何帮助将不胜感激.

提前致谢.

推荐答案

我是这样解决的.希望以后能帮到其他人.

I resolved it like this. Hope this helps somebody else later.

private function onKeyDown( e:KeyboardEvent ) :void
            {
                if( e.keyCode == Keyboard.DOWN || e.keyCode == Keyboard.ENTER)
                {                   
                    focusManager.getNextFocusManagerComponent().setFocus();

                }
                if(e.keyCode == Keyboard.UP)
                {
                    focusManager.getNextFocusManagerComponent(true).setFocus();
                }
            }

在 Flash 中,focusManager 本身在该上下文中可能未定义.改成:evt.currentTarget.focusManager.getNextFocusManagerComponent().setFocus();

In Flash, focusManager by itself may be undefined in that context. Change to: evt.currentTarget.focusManager.getNextFocusManagerComponent().setFocus();

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

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