Gxt Focus Control

I work with Gxt. I need to set focus to the first allowed field on the page. But I have many pages, and I want to centralize this behavior. There is no documentation in Gxt, so I am wondering if anyone has encountered such a problem and can help me.

Now this happens in every component class.

protected void resetFocus() {
    combobox.focus();
}

@Override
public void show() {
    super.show();
    resetFocus();
}

I found com.extjs.gxt.ui.client.aria.FocusManager, but it is completely unclear how I can use it. Or, perhaps you can also get a chain of fields, as they go along the component in accordance with the focus. And I can move the resetFocus method to the parent class.

Smth like this

protected void resetFocus() {
    *getFocusChain().get(0).focus();*
}
+5
source share
2 answers

, GXT3, :

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

, , , .

+3

Scheduler.get().scheduleDeferred. DeferredCommand GWT 1.7 .

:

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

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

All Articles