GXT焦点管理
我正在与 Gxt 合作。我需要将焦点设置到页面上第一个启用的字段。但我有很多页面,我想集中这些行为。 Gxt 缺乏文档,所以我想知道是否有人遇到过这样的问题并可以帮助我。
现在,在每个组件的类中,
protected void resetFocus() {
combobox.focus();
}
@Override
public void show() {
super.show();
resetFocus();
}
我都找到了 com.extjs.gxt.ui.client.aria.FocusManager,但完全不清楚如何使用它。或者也许也可以根据焦点在组件上获取字段链。我可以将resetFocus 方法移至父类。
像那样
protected void resetFocus() {
*getFocusChain().get(0).focus();*
}
I am working with Gxt. I need to set focus to the first enabled field on the page. But I have a lot of pages and I want to centralize that behaviour. There is a lack of documentation in Gxt so I wonder if somebody has met such a problem and can help me.
Now it goes like that in each component's class
protected void resetFocus() {
combobox.focus();
}
@Override
public void show() {
super.show();
resetFocus();
}
I have found com.extjs.gxt.ui.client.aria.FocusManager but is absolutely unclear how can I use it. Or maybe It is also possible to get chain of fields as they go on the component according to the focus. And I can move resetFocus method to the parent class.
Smth like that
protected void resetFocus() {
*getFocusChain().get(0).focus();*
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据最后的响应,我通过执行以下操作使其在 GXT3 窗口中工作:
这样,当窗口打开时,该字段具有焦点,您可以开始键入。
Based on the last response, I got this to work in a GXT3 window by doing the following:
This way when the window opens, the field has focus and you can begin typing.
渲染延迟后聚焦
所以你必须使用
Scheduler.get().scheduleDeferred
方法。或者 GWT 1.7 或更早版本上的DeferredCommand
。使用示例:
Focus after render some delay
So you have to use
Scheduler.get().scheduleDeferred
method. OrDeferredCommand
on GWT 1.7 or before.Example of usage: