UI Toolbox logoUI Toolbox

SpellCheck

SpellCheck is a manipulator that draws a wave in the danger color under the wrong words of a TextField. A right-click on a wrong word, or Shift+F10 or the Menu key with the caret in it, opens a menu with up to five suggestions, "Add to dictionary" and "Ignore". SpellCheckField is a TextField with a SpellCheck. A password field is not checked.

<UIToolbox.SpellCheckField label="Note" multiline="true" />
// Any TextField, also an AutoCompleteField
var check = new SpellCheck();
chatLine.AddManipulator(check);
// Save the added words with the game settings, and add them again at start
settings.Words = SpellChecker.English.AddedWords.ToList();
foreach (var word in settings.Words) SpellChecker.English.AddWord(word);
Member Description
SpellChecker.English The US English checker: the SCOWL size 60 list (about 109 000 words) in Resources/UIToolbox/SpellCheck/en-US.txt, loaded at the first use.
SpellChecker.FromText(text), new SpellChecker(words) A checker from another list, one word on each line. A header that ends with a "---" line, empty lines and lines that start with '#' are skipped.
IsCorrect(word) True for a word in the list. A capitalized word also matches its lowercase form, and a word in capitals both forms. A curly apostrophe matches a straight one.
Suggest(word, max) The list words one or two edits away (a deleted, inserted, changed or swapped letter), the nearest first, in the case of the word.
FindErrors(text) The ranges of the wrong words. A hyphen splits words. Mail and web addresses, and words next to a digit, are not checked.
AddWord(word), AddedWords, WordAdded Add a word to the checker. The fields that use the checker check again.
SpellCheck.Checker The checker of a field. The default is SpellChecker.English.
Errors, IgnoredWords, Check(), ShowMenuAt(index) The wrong words of the field, the words that "Ignore" skips in this field, a new check, and the menu for the word at an index.
Checked Raised after each check, when Errors is new: a change of the value, a new word in the checker, "Ignore" and Check(). Use it to show the number of wrong words beside the field.

Styling

Class Element
tb-spell-check The field with a SpellCheck.
tb-spell-check__marks The element over the text that draws the waves. Its color is the color of the waves: --tb-color-danger. The rule is .tb-spell-check .unity-label.tb-spell-check__marks.

The menu is a ContextMenuComponent, with the menu classes.