Flex 3 focusManager.getNextFocusManagerComponent() 返回 null
我有一个应用程序,我希望让 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
focusManager.moveFocus(FocusRequestDirection.FORWARD);
尝试一下;
focusManager.moveFocus(FocusRequestDirection.FORWARD);
try it;
我也有同样的问题。
很明显 - 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.
如果 focusManager 是 mx.core.Application 的属性,则效果很好
works well if focusManager is a property of mx.core.Application
这似乎是一个错误。 我观察到它发生在设置了 defaultButtons 的表单周围。
It seems to be a bug. I have observed it occurs around forms with defaultButtons set.
你能尝试一下吗:
希望它有效...如果不让我知道,我会在 Flex 构建器中尝试它!
Can you try with:
Hope it works... if not let me know and I will try it in flex builder!