Changes

Jump to: navigation, search

Labs/Ubiquity/Ubiquity Source Tip Author Tutorial

673 bytes removed, 01:35, 22 June 2009
Using CreateCommand
In the example above, we simply call <code>displayMessage()</code>, which displays the given message in whichever way the operating system can.
== Using CreateCommand ==
For commands that are more complicated than our simple "hello-world" command, you can use the helper function <code>CmdUtils.CreateCommand()</code>, which takes an options dictionary. To redo the "hello-world" command using the convenience function, we'd write: <pre>CmdUtils.CreateCommand({ name: "hello-world", execute: function() { displayMessage( "Hello, World!" ); }})</pre> This may not seem to be much of a win (and it isn't for simple commands) but as the commands become more complex, you'll see that it helps a lot. For one, you can name the command more freely with the method&mdash;unicode non-English characters are now fair game. There are a number of other useful functions in the <code>CmdUtils </code> namespace. We don't yet have full documentation for these commands, but you'll get a sense of the useful ones in this tutorial. For more detailed information, take a look at [http://hg.toolness.com/ubiquity-firefox/file/9a6c9935da9f/ubiquity/chrome/content/cmdutils.js cmdutils.js].
== Adding a Preview ==
1,007
edits

Navigation menu