252
edits
Legoboyvdlp (talk | contribs) (→setlistener(): OOP and setlistener) |
m (→setlistener()) |
||
Line 100: | Line 100: | ||
<tt>setlistener()</tt> returns a unique listener id on success, and <tt>nil</tt> on error. The id is nothing else than a counter that is 0 for the first Nasal listener, 1 for the second etc. You need this id number to remove the listener. Most listeners are never removed, so that one doesn't assign the return value, but simply drop it. | <tt>setlistener()</tt> returns a unique listener id on success, and <tt>nil</tt> on error. The id is nothing else than a counter that is 0 for the first Nasal listener, 1 for the second etc. You need this id number to remove the listener. Most listeners are never removed, so that one doesn't assign the return value, but simply drop it. | ||
Listener callback functions can access up to four values via regular function arguments | '''Listener callback functions''' can access up to four values via regular function arguments. | ||
The first two of which are property nodes in the form of a <tt>props.Node()</tt> object hash. | |||
The third is a indication of the operation: 0 for changing the value, -1 for removing a child node, and +1 for adding a child. | |||
The fourth indicates whether the event occurred on the node that was listened to and is always 0 if the previous argument is not 0. | |||
Here is the syntax supposing you have set a callback function named ''myCallbackFunc'' via <tt>setlistener</tt> (''setlistener(myNode, myCallbackFunc)''): | Here is the syntax supposing you have set a callback function named ''myCallbackFunc'' via <tt>setlistener</tt> (''setlistener(myNode, myCallbackFunc)''): |
edits