[Laszlo-user] Trying to assign events dynamically using, delegates.

André Bargull a.bargull at intensis.de
Mon Jul 21 14:14:59 PDT 2008


When you create a delegate, you need specify which method on which 
object should be called.
So in this case, the object is the canvas and the method is "test2".

> //create the delegate
> if ( typeof delete_button.del == "undefined" ) {
>     delete_button.del = new LzDelegate( *canvas*, "test2");
> }


> Why does it have to be defined "on" the button, it's defined in the  
> source, which you can view here. Thanks for your time.
>
> http://github.com/xkenneth/buildoutbuilder/tree/master/buildoutbuilder.laszlo/src
>
> buildoutbuilder.lzx is the file you're looking for.
>
> Thanks again!
>
> Regards,
> Ken
>
> On Jul 21, 2008, at 3:18 PM, Henry Minsky wrote:
>
> >/ Do you have a "test2" method defined on button? It would seem to me
> />/ that you don't, because you're instantiating
> />/ it right there, and there is no test2 method defined in the lz button
> />/ component class, that I know of..
> />/
> />/
> />/ On Mon, Jul 21, 2008 at 4:06 PM, Kenneth Miller <xkenneth at gmail.com <http://www.openlaszlo.org/mailman/listinfo/laszlo-user>>  
> />/ wrote:
> />>/ All,
> />>/    Here's the error: ERROR @lz/button.lzx#35: Invalid delegate:  
> />>/ button
> />>/ text=Delete.test2 => «undefined» (must be a Function)
> />>/ Regards,
> />>/ Ken
> />>/ On Jul 21, 2008, at 2:00 PM, Henry Minsky wrote:
> />>/
> />>/ You can call a method on another object,  using a delegate, but you'd
> />>/ have to create the delegate to point to your object
> />>/
> />>/ e.g.,
> />>/
> />>/ new LzDelegate(yourinstance, "test2")
> />>/
> />>/ Your delegate was created to call the test2 method on your button  
> />>/ instance.
> />>/ ...
> />>/
> />>/
> />>/
> />>/ On Mon, Jul 21, 2008 at 2:59 PM, Henry Minsky <hminsky at laszlosystems.com <http://www.openlaszlo.org/mailman/listinfo/laszlo-user> 
> />>/ >
> />>/ wrote:
> />>/
> />>/ What is the error? Your test2 method is never getting called? Where  
> />>/ is
> />>/
> />>/ the "test2" method being declared on
> />>/
> />>/ the button class?  Don't you need a subclass of button, in order to
> />>/
> />>/ define your method on it?
> />>/
> />>/
> />>/ On Mon, Jul 21, 2008 at 2:40 PM, Kenneth Miller  
> />>/ <xkenneth at gmail.com <http://www.openlaszlo.org/mailman/listinfo/laszlo-user>> wrote:
> />>/
> />>/ I'm trying to create a new button here and attach an event to it,  
> />>/ can anyone
> />>/
> />>/ tell me what I'm doing wrong?
> />>/
> //>> [...]
> /



More information about the Laszlo-user mailing list