how to fire a element's event?

27 views
Skip to first unread message

wahaha

unread,
Nov 28, 2011, 8:29:31 AM11/28/11
to Google Web Toolkit
there is instance of Element(not Widget),how to fire its click event?

András Csányi

unread,
Nov 28, 2011, 8:45:01 AM11/28/11
to google-we...@googlegroups.com
On 28 November 2011 14:29, wahaha <il...@yahoo.com.cn> wrote:
> there is instance of Element(not Widget),how to fire its click event?

Attach to it an ClickHandler. Go through this example and you will
find an god example.

http://www.vogella.de/articles/GWT/article.html

--
- -
--  Csanyi Andras (Sayusi Ando)  -- http://sayusi.hu --
http://facebook.com/andras.csanyi
--  ""Trust in God and keep your gunpowder dry!" - Cromwell

Thomas Broyer

unread,
Nov 28, 2011, 9:18:38 AM11/28/11
to google-we...@googlegroups.com
All browsers (I believe, you'd better double-check though) implement a click() method on elements, that fire a click event as if the user actually clicked, so either you call it with JSNI, or you cast your Element to a ButtonElement or InputElement and call its click() method:

public static native void click(Element elem) /*-{ elem.click(); }-*/;
...
click(myElem);

or

myElem.<ButtonElement>cast().click();
Reply all
Reply to author
Forward
0 new messages