From 714504b548281bff3c115a219baa4e44fa2857c0 Mon Sep 17 00:00:00 2001 From: mfranz Date: Mon, 30 Jan 2006 12:37:34 +0000 Subject: [PATCH] support optional setlistener() arg to fire callback function initially; copy arg checking from interpolate() --- Nasal/globals.nas | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Nasal/globals.nas b/Nasal/globals.nas index c14f8785c..ca857b60c 100644 --- a/Nasal/globals.nas +++ b/Nasal/globals.nas @@ -66,10 +66,13 @@ interpolate = func { ## # Convenience wrapper for the _setlistener function. Takes a # single string or props.Node object in arg[0] indicating the -# listened to property, and a function in arg[1]. +# listened to property, a function in arg[1], and an optional +# bool in arg[2], which triggers the function initially if true. # setlistener = func { - _setlistener(isa(arg[0], props.Node) ? arg[0]._g : arg[0], arg[1]); + if(isa(arg[0], props.Node)) { arg[0] = arg[0]._g; } + elsif(typeof(arg[0]) != "scalar") { return; } + _setlistener(arg[0], arg[1], size(arg) > 2 ? arg[2] : 0); }