GXT焦点管理

发布于 2024-09-30 03:08:57 字数 483 浏览 0 评论 0原文

我正在与 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 技术交流群。

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

发布评论

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

评论(2

面犯桃花 2024-10-07 03:08:57

根据最后的响应,我通过执行以下操作使其在 GXT3 窗口中工作:

@Override
public void show() {
    super.show();
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            field.focus();
        }
    });
}

这样,当窗口打开时,该字段具有焦点,您可以开始键入。

Based on the last response, I got this to work in a GXT3 window by doing the following:

@Override
public void show() {
    super.show();
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
        @Override
        public void execute() {
            field.focus();
        }
    });
}

This way when the window opens, the field has focus and you can begin typing.

盛夏已如深秋| 2024-10-07 03:08:57

渲染延迟后聚焦
所以你必须使用 Scheduler.get().scheduleDeferred 方法。或者 GWT 1.7 或更早版本上的 DeferredCommand

使用示例:

Scheduler.get().scheduleDeferred(new ScheduledCommand() {

    @Override
    public void execute() {
        widget.focus();
        widget.el().focus();
        widget.getElement().focus();
    }
});

Focus after render some delay
So you have to use Scheduler.get().scheduleDeferred method. Or DeferredCommand on GWT 1.7 or before.

Example of usage:

Scheduler.get().scheduleDeferred(new ScheduledCommand() {

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