Adobe Extending Dreamweaver CS4 Manuel d'utilisateur Page 160

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 387
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 159
154
EXTENDING DREAMWEAVER CS4
Menus and menu commands
function canAcceptCommand()
{
var selarray;
if (arguments.length != 1) return false;
var bResult = false;
var whatToDo = arguments[0];
if (whatToDo == "undo")
{
bResult = dw.canUndo();
}
else if (whatToDo == "redo")
{
bResult = dw.canRedo();
}
return bResult;
}
receiveArguments()
Dreamweaver calls the receiveArguments() function to process any arguments that you defined for the menuitem
tag. For the Undo and Redo menu items, the
receiveArguments() function calls either the dw.undo() function or
the
dw.redo() function, depending on whether the value of the argument, arguments[0], is "undo" or "redo". The
dw.undo() function undoes the previous step that the user performed in the document window, dialog box, or panel
that has focus. The
dw.redo() function redoes the last operation that was undone.
The receiveArguments() function looks like the following example code:
function receiveArguments()
{
if (arguments.length != 1) return;
var whatToDo = arguments[0];
if (whatToDo == "undo")
{
dw.undo();
}
else if (whatToDo == "redo")
{
dw.redo();
}
}
In this command, the receiveArguments() function processes the arguments and executes the command. More
complex menu commands might call different functions to execute the command. For example, the following code
checks whether the first argument is
"foo"; if it is, it calls the doOperationX() function and passes it the second
argument. If the first argument is
"bar", it calls the doOperationY() function and passes it the second argument. The
doOperationX() or doOperationY() function is responsible for executing the command.
Vue de la page 159
1 2 ... 155 156 157 158 159 160 161 162 163 164 165 ... 386 387

Commentaires sur ces manuels

Pas de commentaire