Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How do I click a button programmatically?

    Example:
    On a simple login screen I want to allow the user to type 'Enter' after entering the username and password to fire the login button's click event. But what code goes in the onKeyPress method of the username and password fields' KeyPressHandler to click the button? I'm sure I am overlooking something simple, but I just can't figure out how to do it.

    On regular GWT buttons, there is a click() method so the call would just be loginButton.click().

    #2
    Use saveOnEnter and override submit().

    General note: don't try to manually fire click(), instead, make your own method and call it from the click handler and from other code.

    Comment


      #3
      Can you please give a simple example with either an IButton or Button? Appreciate in advance. We might also have a need where there's a button outside of a dynamic form that needs to be triggered programmatically.
      Last edited by sujaydutta; 19 Nov 2011, 07:18.

      Comment

      Working...
      X