You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Michael Allman <ms...@allman.ms> on 2010/06/25 07:04:52 UTC
referencing the object behind the wtkx
Hi,
Is it currently possible to get a reference to the object associated with
a loaded WTKX from a script within the WTKX itself?
For example, consider a class named Dog with a method named bark. Let
dog.wtkx be a WTKX file whose root element is the Dog class. Can I call
the bark method of "this" from a script in dog.wtkx?
For now, I'm just injecting the instance of Dog into the wtkx context with
WTKXSerializer.put under very clever the name "self". :)
Cheers.
Michael
Re: referencing the object behind the wtkx
Posted by Michael Allman <ms...@allman.ms>.
Awesome, dude. Thanks.
Michael
On Fri, 25 Jun 2010, Greg Brown wrote:
>> For example, consider a class named Dog with a method named bark. Let dog.wtkx be a WTKX file whose root element is the Dog class. Can I call the bark method of "this" from a script in dog.wtkx?
>
> Yes, you can do this. For example, you could give the Dog instance an ID and then call it from script:
>
> <Dog wtkx:id="dog">
> <wtkx:script>
> dog.bark();
> </wtkx:script>
> </Dog>
>
> Though generally you would probably do this in an event handler, not inline as the file is being processed.
>
>
Re: referencing the object behind the wtkx
Posted by Greg Brown <gk...@mac.com>.
> For example, consider a class named Dog with a method named bark. Let dog.wtkx be a WTKX file whose root element is the Dog class. Can I call the bark method of "this" from a script in dog.wtkx?
Yes, you can do this. For example, you could give the Dog instance an ID and then call it from script:
<Dog wtkx:id="dog">
<wtkx:script>
dog.bark();
</wtkx:script>
</Dog>
Though generally you would probably do this in an event handler, not inline as the file is being processed.