Package | com.adobe.linguistics.spelling |
Class | public class SpellUI |
Inheritance | SpellUI ![]() |
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 1.0, Flash Player 10 |
A comprehensive convenience class that bundles a context menu UI, the spelling engine, the dictionary loader, and user dictionary support to enable a single-line integration of spell checking functionality into any text related Flex UI component. While this class drastically simplifies the effort to enable spell checking functionality in a Flex UI component, it does shield the developer form controlling detailed behaviors of the spell checker and the user dictionary storage options.
This class provides a simple UI for some standard Flex UI components. It is not intended to address a complete user interface. Instead, it presents a basic user interface for some commonly used Flex UI components.
For advanced text editing applications, more complex features are likely required.
For those applications, we recommend bypassing this class and utilizing the SpellChecker
class directly.
SpellUI
uses the SpellingConfig.xml file to lookup corresponding resource files for a given locale.
The default location of SpellingConfig.xml is [yourapplicationDirectory]/SpellingConfig.xml. This could be customized using
spellingConfigUrl
property of SpellUI
. You don't have to change the content of this file. However,
if you want to add a new language, to use an alternative dictionary or to customize the location for your dictionaries, you can modify it.
There's an known issue with IIS web server when loading dictionary files with unknown extensions, in which case you can modify the XML to work around it.
A sample SpellingConfig.xml will look as follows:
<?xml version="1.0" encoding='UTF-8'?> <SpellingConfig> <LanguageResource language="English" languageCode="en_US" ruleFile="dictionaries/en_US/en_US.aff" dictionaryFile="dictionaries/en_US/en_US.dic"/> <LanguageResource language="Spanish" languageCode="es_ES" ruleFile="dictionaries/es_ES/es_ES.aff" dictionaryFile="dictionaries/es_ES/es_ES.dic"/> <LanguageResource language="Portuguese" languageCode="pt_PT" ruleFile="dictionaries/pt_PT/pt_PT.aff" dictionaryFile="dictionaries/pt_PT/pt_PT.dic"/> <LanguageResource language="Italian" languageCode="it_IT" ruleFile="dictionaries/it_IT/it_IT.aff" dictionaryFile="dictionaries/it_IT/it_IT.dic"/> </SpellingConfig>
Property | Defined By | ||
---|---|---|---|
spellingConfigURL : String [static]
The URL for the spelling config xml file. | SpellUI |
Method | Defined By | ||
---|---|---|---|
disableSpelling(comp:UIComponent):void [static]
Disable the spell checking feature for a UI component. | SpellUI | ||
enableSpelling(comp:UIComponent, lang:String):void [static]
Enable the spell checking feature in the specified language for a UI component. | SpellUI | ||
getSpellingMenuEntries():Object [static]
Get the spelling context menu entries. | SpellUI | ||
setSpellingMenuEntries(entries:Object):Boolean [static]
Set the spelling context menu entries. | SpellUI |
spellingConfigURL | property |
spellingConfigURL:String
The URL for the spelling config xml file. If you haven't specified it, the default URL is [applicationDirectory]/SpellingConfig.xml. Note that we don't validate the URL, if the file doesn't exist, you will get an error when calling enableSpelling() function.
public static function get spellingConfigURL():String
public static function set spellingConfigURL(value:String):void
SpellUI.spellingConfigUrl = "./config/MySpellingConfig.xml"; SpellUI.enableSpelling(textArea, "es_ES");
disableSpelling | () | method |
public static function disableSpelling(comp:UIComponent):void
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 1.0, Flash Player 10 |
Disable the spell checking feature for a UI component.
Parameters
comp:UIComponent — A text editing Flex UI component.
|
enableSpelling | () | method |
public static function enableSpelling(comp:UIComponent, lang:String):void
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 1.0, Flash Player 10 |
Enable the spell checking feature in the specified language for a UI component. Once a component is spell checking enabled, misspelled words will be highlighted with a squiggly line. Users can right click on a misspelled word to see the suggestions in the context menu.
Parameters
comp:UIComponent — A text editing Flex UI component. It can be a mx TextArea , TextInput or RichTextEditor .
If you are using AdobeSpellingUIEx.swc, it can also be a spark TextArea or TextInput .
| |
lang:String — The language code used for spell checking, for example en_US . it will lookup the SpellingConfig.xml file to access corresponding resource files.
SpellingConfig.xml should be located at the same folder as your main mxml source file. You don't have to change the content of this file. However,
if you want to add a new language, to use an alternative dictionary or to customize the location for your dictionaries, you can modify it. There's an known issue with
IIS web server when loading dictionary files with unknown extensions, in which case you can modify the XML to work around it.
|
getSpellingMenuEntries | () | method |
public static function getSpellingMenuEntries():Object
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 1.0, Flash Player 10 |
Get the spelling context menu entries.
ReturnsObject — A flex Object containing the spelling context menu entries. If you haven't customized the entries, you get the default associative array {enable:"Enable Spelling", disable:"Disable Spelling", add:"Add to dictionary"}
|
setSpellingMenuEntries | () | method |
public static function setSpellingMenuEntries(entries:Object):Boolean
Language Version : | ActionScript 3.0 |
Runtime Versions : | AIR 1.0, Flash Player 10 |
Set the spelling context menu entries. This uses the flex object as an associative array for extensibility.
entries
should have all the customized contextMenu entries including enable (spelling),
disable (spelling) and add (to dictionary)
. To ensure a consistent contextMenu within your application,
the spelling context menu entries you provide here are applied to all UI components. We recommend you use this API
with Flex resource for localization. Make sure to also have a look at the Flex localization documentation.
Parameters
entries:Object — A flex Ojbect that looks like entries:Object = {enable:"Enable Spelling", disable:"Disable Spelling",
add:"Add to dictionary"} . If you don't customize the contextMenu, the default contextMenu in English will be used.
We recommend that you use the Flex localization resource to obtain these strings.
|
Boolean — True if the spelling menu is successfully customized, false if it fails. Possible failure
reasons include passing the wrong object or missing some required entries. If the function fails, the contextMenu is left unchanged.
|
See also