On 3 déc, 17:34, Davidj2k <[email protected]> wrote:
> I am needing to pass a function from javascript to the java code to
> fire an event so that when a button is created using Java I can pass
> to it the function to call when that button is clicked, any help would
> be greatly appreciated.
>
> the javascript
>
> function onclick()
> {
>      alert('I was clicked');
>
> }
>
> myObject.addOnclick(onclick());
>
> or it could be
>
> myObject.onclickevent = onclick();
>
> the java
>
> public void addOnClick(NOT SURE WHAT TO PASS HERE)

public void addOnClick(final JavaScriptObject func)

>         {
>                  SelectionListener<ButtonEvent> l = new
> SelectionListener<ButtonEvent>() {
>                     @Override
>                     public void componentSelected(ButtonEvent ce) {
>                         THEN CALL THE JAVASCRIPT FUNCTION HERE

callFunc(func);

>                     }
>                 };
>         }

private native void callFunc(JavaScriptObject func) /*-{
   func();
}-*/;

--

You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.


Reply via email to