Fire a button click event programmatically

1,410 views
Skip to first unread message

zhong

unread,
Dec 8, 2010, 6:27:53 PM12/8/10
to Google Web Toolkit
Hi,

Is there a way to fire a button click event programmatically?

Many thanks,
Zhong

Nick Newman

unread,
Dec 8, 2010, 6:42:56 PM12/8/10
to google-we...@googlegroups.com
Might be simpler and clearer to have the button click event call a method, and simply call that method directly.

Nick


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
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.


Gaurav Vaish

unread,
Dec 9, 2010, 12:59:08 AM12/9/10
to Google Web Toolkit
Native javascript:

btnElement.click()



--
Happy Hacking,
Gaurav Vaish
http://www.mastergaurav.com



On Dec 9, 4:42 am, Nick Newman <nick.x.new...@gmail.com> wrote:
> Might be simpler and clearer to have the button click event call a method,
> and simply call that method directly.
>
> Nick
>
> On Wed, Dec 8, 2010 at 4:27 PM, zhong <zhongl...@gmail.com> wrote:
> > Hi,
>
> > Is there a way to fire a button click event programmatically?
>
> > Many thanks,
> > Zhong
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Web Toolkit" group.
> > 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<google-web-toolkit%2Bunsu...@googlegroups.com>
> > .

Jim Douglas

unread,
Dec 9, 2010, 1:17:25 AM12/9/10
to Google Web Toolkit
The GWT Button Widget is actually an HTML button object; it exposes
button.click():

http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/user/client/ui/Button.html#click()

But GWT CustomButtons (PushButton/ToggleButton) are really styled
DIVs, not HTML button objects, so the native click() method isn't an
option. For CustomButtons, you have to write code that invokes
whatever it is you want to do when the user clicks the button.

http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/user/client/ui/CustomButton.html

On Dec 8, 9:59 pm, Gaurav Vaish <gaurav.va...@gmail.com> wrote:
> Native javascript:
>
> btnElement.click()
>
> --
> Happy Hacking,
> Gaurav Vaishhttp://www.mastergaurav.com
>
> On Dec 9, 4:42 am, Nick Newman <nick.x.new...@gmail.com> wrote:
>
>
>
> > Might be simpler and clearer to have the button click event call a method,
> > and simply call that method directly.
>
> > Nick
>
> > On Wed, Dec 8, 2010 at 4:27 PM, zhong <zhongl...@gmail.com> wrote:
> > > Hi,
>
> > > Is there a way to fire a button click event programmatically?
>
> > > Many thanks,
> > > Zhong
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Google Web Toolkit" group.
> > > 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<google-web-toolkit%2Bunsubs cr...@googlegroups.com>

zhong

unread,
Dec 9, 2010, 8:56:40 AM12/9/10
to Google Web Toolkit
It works with button.click()

Thanks a lot!

On Dec 9, 1:17 am, Jim Douglas <jdou...@basis.com> wrote:
> The GWT Button Widget is actually an HTML button object; it exposes
> button.click():
>
> http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/g...()
>
> But GWT CustomButtons (PushButton/ToggleButton) are really styled
> DIVs, not HTML button objects, so the native click() method isn't an
> option.  For CustomButtons, you have to write code that invokes
> whatever it is you want to do when the user clicks the button.
>
> http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/g...
Reply all
Reply to author
Forward
0 new messages