Flex 3 focusManager.getNextFocusManagerComponent() 返回 null

发布于 2024-07-25 21:59:30 字数 501 浏览 6 评论 0原文

我有一个应用程序,我希望让 Enter 键像 Tab 键一样工作。 我可以轻松捕获按键事件并将焦点设置到文本输入字段。 问题是确定要关注哪个文本输入字段。 我有这段代码


trace(this.window.focusManager);
//returns TheWindow86.focusManager

trace(this.window.focusManager.getNextFocusManagerComponent());
//returns null

//This is what I was hoping would work
this.window.focusManager.getNextFocusManagerComponent().setFocus();

代码位于控制器类中,“this.window”引用了 nativeWindow mxml 文件“TheWindow.mxml”的实例。 第一个跟踪按预期工作,但第二个跟踪给出 null。 最后一行是我想要工作的代码。

I have an app where I am looking to make the enter key act like a tab key. I can easily capture the keypress event and setFocus to a textinput field. The problem is figuring out which textinput field to give focus to. I have this code


trace(this.window.focusManager);
//returns TheWindow86.focusManager

trace(this.window.focusManager.getNextFocusManagerComponent());
//returns null

//This is what I was hoping would work
this.window.focusManager.getNextFocusManagerComponent().setFocus();

The code is in a controller class and "this.window" references an instance of a nativeWindow mxml file "TheWindow.mxml". The first trace works as expected, but the second one gives null. The last line is the code that I am wanting to work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

随梦而飞# 2024-08-01 21:59:30

focusManager.moveFocus(FocusRequestDirection.FORWARD);

尝试一下;

focusManager.moveFocus(FocusRequestDirection.FORWARD);

try it;

为你鎻心 2024-08-01 21:59:30

我也有同样的问题。
很明显 - this.window.focusManager.getNextFocusManagerComponent().setFocus(); - 给你一个错误,因为 - this.window.focusManager.getNextFocusManagerComponent() - 返回 null。

我不明白为什么 focusManager 不知道接下来会出现什么组件......这就是问题所在。

I've got the same problem.
It's clear that - this.window.focusManager.getNextFocusManagerComponent().setFocus(); - gives to you en error because - this.window.focusManager.getNextFocusManagerComponent() - returns null.

I can't realize why focusManager doesn't know what component would come next... there is the problem.

心不设防 2024-08-01 21:59:30
focusManager.moveFocus(mx.events.FocusRequestDirection.FORWARD);

如果 focusManager 是 mx.core.Application 的属性,则效果很好

focusManager.moveFocus(mx.events.FocusRequestDirection.FORWARD);

works well if focusManager is a property of mx.core.Application

翻身的咸鱼 2024-08-01 21:59:30

这似乎是一个错误。 我观察到它发生在设置了 defaultButtons 的表单周围。

It seems to be a bug. I have observed it occurs around forms with defaultButtons set.

高跟鞋的旋律 2024-08-01 21:59:30

你能尝试一下吗:

this.window.focusManager.setFocus(this.window.focusManager.getNextFocusManagerComponent());

希望它有效...如果不让我知道,我会在 Flex 构建器中尝试它!

Can you try with:

this.window.focusManager.setFocus(this.window.focusManager.getNextFocusManagerComponent());

Hope it works... if not let me know and I will try it in flex builder!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文