Changes

Jump to: navigation, search

Labs/Ubiquity/Ubiquity Source Tip Author Tutorial

1,239 bytes removed, 05:32, 22 June 2009
Defining Synonyms for your Command
</pre>
== Defining Synonyms for your Command ==
To make it easier for users to discover and use your command, you can give it one or more synonyms. These are alternate names which can be used to invoke the command. For example, if we wanted the "twitter" command to also be invokable by the name "tweet", we could do:
 
<pre>
CmdUtils.CreateCommand({
name: "twitter",
synonyms: ["tweet"],
// etc etc...
});
</pre>
 
Now if the user types "tweet", the Twitter command will be suggested.
 
The synonyms attribute, if present, must be an array. The array can contain any number of synonyms.
 
But wait, you may be saying, what happens if the user later installs a different command that is actually called "Tweet"? Won't there be a conflict?
 
The answer is that the Ubiquity suggestion list always sorts synonym-based suggestions lower than directly-matched names. So if there is no "tweet" command, and the user types "tweet", then Ubiquity will suggest "twitter". But if there is a "tweet" command, and the user types "tweet", Ubiquity will suggest "tweet" first and "twitter" second.
 
This means that defining synonyms for your command will never get in the way of other peoples' commands. So feel free to create synonyms with impunity!
== Implementing Asynchronous Noun Suggestions ==
1,007
edits

Navigation menu