SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 1945 | Next

Joseph W. Lowery

"Dreamweaver CS3 Bible"

You can see the return value variable in operation in the
standard Display Status Message behavior.
The document.MM_returnValue variable is declared as the last line in the function definition. Thus,
Display Status Message reads as follows:
function MM_displayStatusMsg(msgStr) { //v2.0
status = msgStr;
document.MM_returnValue = true;
}
Naturally, the return value could also be false.
Including multiple functions
Although it was not widely used, the capability to return multiple functions began in Dreamweaver 1.2.
Previously, all behavior functions had to be self-contained, and one could not call on any helper functions.
Now, however, multiple functions can easily be defined and returned via behaviorFunction(). After
they are written into the user??™s page, all the returned functions are stored in a single
tag pair.
The technique for inserting multiple functions is fairly straightforward. First, list the defined functions in a
comma-delimited string in behaviorFunction(). The one trick is to make sure that your primary function
??”the one called by the event handler??”is listed not first, but last. This technique is illustrated in the
following code for my custom Resize Layer Patch behavior:
function behaviorFunction() {
return ???reDo,resizePatch??™;
}
Here, the primary function is resizePatch() and is used as such in applyBehavior():
function applyBehavior() {
return ???resizePatch()??™; //return fn call with args
}
BC 56
Creating a Behavior
Summary
Although creating a custom behavior is not a simple task, it is a vastly rewarding one??”from both the programmer??™s
and the user??™s perspectives.


Pages:
1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946