Search code examples
iphoneandroidgwtsetfocusmobile-webkit

GWT focus problem when triggered elsewhere


Here is my setup:

  • I have a button and a textbox
  • The textbox has an "onFocus" Handler which triggers the "selectAll" method
  • the button has an "onClick" Handler which does the following:
    • show textbox
    • textbox.focus(true) and
    • textbox.selectAll();

But it does not (on mobile devices). The thing is: this works in FF and Safari - but it does not on mobile WebKit. When I click the button the field gets focused and selected for a milisecond (sometimes not even that) and then returns to focus the button …

A already tried to insert a Timer which then would do the focus - does not work either.

I also tried to capture all events and prevent them - because there is an onFocus event being fired by the button after onClick. I even tried setting the focus to the textbox from the onFocus event of the button. No chance.

Any other Ideas?


Solution

  • The problem is that GWT doesn't compile Javascript code for touch devices. You will need to create your own implementation.

    Take a look to this article: Supporting multi-touch events