Attaches a handler method for the named event to the object that contains this element.
The name
attribute gives the event for which this handler should be invoked.
Events can be declared via the event
tag. Events are also generated whenever the value of an attribute is changed using the setAttribute
method.
For example, if a handler is defined via:
<view id="obj"> <hander name="onkeydown" args="kc"> if (kc == 13) this.doAction() </handler> <method name="doAction"> Debug.write("action"); </method> </view>
then script code
obj.onmyevent.sendEvent(259)
will output "action".
The argument passed to an event handler is whatever value was used in the call to sendEvent() which generated the event. In the case where an attribute value is set using setAttribute, the new value is sent as the argument to sendEvent, and that will be the argument value received to any user-defined handler for that event.
If the @method attribute is given, a method body is unnecessary and the named method will be invoked instead. For example, the handler below has the same behavior as the earlier example.
<view id="obj"> <hander name="onkeydown" method="doAction"/> <method name="doAction" args="kc"> if (kc == 13) Debug.write("action"); </method> </view>
Copyright © 2002-2007 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.