I understand now, I was going about it wrong
myObject.addOnclick(function() {
alert('I was clicked');
});
On Fri, Dec 4, 2009 at 8:45 AM, David Jordan <[email protected]> wrote:
> When I try using that the myObject.addOnclick(onclick()); the function I
> am trying to pass in actually executes at that time, and when I look at the
> value of final JavaScriptObject func it has a value of null and then when
> the button that I am trying to create is clicked the value of func is null
> as well.
>
>
> On Thu, Dec 3, 2009 at 2:52 PM, Thomas Broyer <[email protected]> wrote:
>
>>
>>
>> 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]<google-web-toolkit%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-web-toolkit?hl=en.
>>
>>
>>
>
--
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.