Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gxt focus management

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();*
}
like image 729
Zalivaka Avatar asked Nov 03 '10 13:11

Zalivaka


1 Answers

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.

like image 112
Lindsay Thurmond Avatar answered Sep 25 '22 16:09

Lindsay Thurmond