How to set default textbox on form?

61 views
Skip to first unread message

Blake McBride

unread,
Apr 23, 2012, 10:15:35 PM4/23/12
to Google Web Toolkit
Greetings,

Is there a way to set which widget (usually a certain textbox) that should be the default widget with focus when a new form appears?  Basically when the new form appears, if the user just starts typing, the input should appear in the widget that was specified as the one with the default focus.

(I discovered that the order that the widgets are defined in the source file determines the tab order.  This order can be changed in designer mode by changing the order in the widget list for the form via dragging.)

Thanks.

Blake McBride

Qian Qiao

unread,
Apr 23, 2012, 10:26:12 PM4/23/12
to google-we...@googlegroups.com

Widgets that can be focused on all have setTabIndex method. Don't know
if this is what you want.

Worst case, yon can override the onAttach method of your form
container, and do textbox.setFocus(true)

HTH.

-- Joe

Thomas Broyer

unread,
Apr 24, 2012, 6:13:25 AM4/24/12
to google-we...@googlegroups.com

On Tuesday, April 24, 2012 4:15:35 AM UTC+2, Blake wrote:
Greetings,

Is there a way to set which widget (usually a certain textbox) that should be the default widget with focus when a new form appears?  Basically when the new form appears, if the user just starts typing, the input should appear in the widget that was specified as the one with the default focus.

When you're showing the form:
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
   @Override
   public void execute() {
      theTextBox.focus();
   }
});

Blake McBride

unread,
Apr 24, 2012, 4:44:38 PM4/24/12
to google-we...@googlegroups.com
Works if I change:

    theTextBox.focus();

into:

    theTextBox.setFocus(true);

Thanks!!

Blake McBride


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/R7RfvP3PGBQJ.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Reply all
Reply to author
Forward
0 new messages