Platforms to show: All Mac Windows Linux Cross-Platform

Back to NSSpellCheckerMBS class.

NSSpellCheckerMBS.availableLanguages as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.7 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns a list of the available languages.

Requires Mac OS X 10.5.

NSSpellCheckerMBS.checkGrammarOfString(text as string, start as Integer, language as string, wrap as boolean) as NSRangeMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initiates a grammatical analysis of a given string.

text: String to analyze.
start: Location within string at which to start the analysis.
language: Language use in string. When nil, the language selected in the Spelling panel is used.
wrap: true to specify that the analysis continue to the beginning of string when the end is reached. false to have the analysis stop at the end of string.
outDetails: Optional. On output, dictionaries describing grammar-analysis details within the flagged grammatical unit. See the NSSpellServer class for information about these dictionaries.

Returns Location of the first flagged grammatical unit.

Available in Mac OS X v10.5 and later.

See also:

Some examples using this method:

NSSpellCheckerMBS.checkGrammarOfString(text as string, start as Integer, language as string, wrap as boolean, Details() as dictionary) as NSRangeMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initiates a grammatical analysis of a given string.

text: String to analyze.
start: Location within string at which to start the analysis.
language: Language use in string. When nil, the language selected in the Spelling panel is used.
wrap: true to specify that the analysis continue to the beginning of string when the end is reached. false to have the analysis stop at the end of string.
outDetails: Optional. On output, dictionaries describing grammar-analysis details within the flagged grammatical unit. See the NSSpellServer class for information about these dictionaries.

Returns Location of the first flagged grammatical unit.

Available in Mac OS X v10.5 and later.

See also:

NSSpellCheckerMBS.checkSpellingOfString(text as string, start as Integer, language as string, wrap as boolean, byref WordCount as Integer) as NSRangeMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Initiates a spell-check of a string.

Returns the range of the first misspelled word (and optionally the wordCount by reference).

See also:

NSSpellCheckerMBS.checkString(text as string, range as NSRangeMBS = nil, checkingTypes as Int64 = -1, options as Dictionary = nil, byref orthography as NSOrthographyMBS, byref wordCount as Integer) as NSTextCheckingResultMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 19.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Requests unified text checking for the given range of the given string.

text: The string to check.
range: The range of the string to check.
checkingTypes: The type of checking to be performed. The possible constants are listed in NSTextCheckingType and can be combined using the C bit-wise OR operator to perform multiple checks at the same time.
options: The options dictionary specifying the types of checking to perform. See Spell Checking Option Dictionary Keys for the possible keys and expected values.

orthography: Returns by-reference, the orthography of the range of the string. See NSOrthographyMBS for more information.
wordCount: Returns by-reference, the word count for the range of the string.

Returns an array of NSTextCheckingResultMBS objects describing particular items found during checking and their individual ranges, sorted by range origin, then range end, then result type.

NSSpellCheckerMBS.completionsForPartialWordRange(start as Integer, length as Integer, text as string, language as string="") as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Searches possible completions for the given word.

Returns an array of strings, in the order in which they should be presented, representing complete words that the user might be trying to type when starting by typing the partial word at the given range in the given string.

Within the text, length characters are picked starting at at position (0 based) and matched agains the dictionary defined by language.
Up to around 100 words are returned.

Requires Mac OS X 10.3.
Returns an empty string on any error.

Some examples using this method:

NSSpellCheckerMBS.correctionForWordRange(range as NSRangeMBS, text as string, language as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 19.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns a single proposed correction if a word is mis-spelled.

range: The range of the word to be corrected.
text: The string containing the proposed correction.
language: The language.

Returns the proposed correct string.

NSSpellCheckerMBS.countWordsInString(word as string, language as string="") as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Just counts the words without checking spelling.
Example
dim text as string = "Hello World"
dim spell as NSSpellCheckerMBS // your spellchecker

msgBox str(spell.countWordsInString(text,"en"))

Returns the number of words in text. The language argument specifies the language used in the string. If language is the empty string, the current selection in the Spelling panel's pop-up menu is used.

Returns -1 if text is nil or this spellchecker function is not available.

Returns -1 if counting words isn't supported by the spell server selected.

Some examples using this method:

NSSpellCheckerMBS.deletesAutospaceBetweenString(precedingString as string, followingString as string, language as String = "") as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 19.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Deletes auto space between strings.

In some cases the space automatically inserted after an accepted candidate should be deleted when the next text is typed (e.g. if it is a period or comma). This method allows clients to recognize these cases in a standardized way.

NSSpellCheckerMBS.dismissCorrectionIndicatorForView(view as NSViewMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 19.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Dismisses the correction indicator for the specified view.

NSSpellCheckerMBS.forgetWord(word as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Removes the given word from the user dictionary.

NSSpellCheckerMBS.guessesForWord(range as NSRangeMBS, word as string, language as string) as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns an array of possible substitutions for the specified string.

range: The range of the string to check.
word: The string to guess
language: The language of the string

Returns an array of strings containing possible replacement words.
Available in Mac OS X v10.6 and later.

See also:

Some examples using this method:

NSSpellCheckerMBS.guessesForWord(word as string) as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns an array with words matching the given word.
Example
dim a() as string
dim s as new NSSpellCheckerMBS
a=s.guessesForWord("Hell")

msgbox str(ubound(a)+1)+" suggestions."

Returns nil on any error.

Returns an array of suggested spellings for the misspelled word word. If word contains all capital letters, or its first letter is capitalized, the suggested words are capitalized in the same way.

See also:

NSSpellCheckerMBS.hasLearnedWord(word as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.7 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Checks whether a word has been learned.

Returns true if the word is known.
Requires Mac OS X 10.5.

NSSpellCheckerMBS.ignoredWords as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The list of ignored words.
Example
dim spell as new NSSpellCheckerMBS
dim f as FolderItem
dim i,c as Integer
dim t as TextOutputStream
dim n(-1) as string

f=SpecialFolder.Preferences.Child("SpellCheck RB.pref")
t=f.CreateTextFile
if t<>nil and spell<>nil then
n=spell.ignoredWords
MsgBox Join(n,EndOfLine)
end if

Returns nil on any error.

Some examples using this method:

NSSpellCheckerMBS.ignoreWord(word as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Adds the word to the ignore list so it will be ignored for spell checking in this NSSpellCheckerMBS object.

Requires Mac OS X 10.2.

Some examples using this method:

NSSpellCheckerMBS.languageForWordRange(range as NSRangeMBS, text as string, orthography as NSOrthographyMBS = nil) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 19.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Clients who have an NSOrthography from NSTextCheckingTypeOrthography checking and wish to determine a specific language from it for a particular word.

NSSpellCheckerMBS.languageMenuEntries as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The entries from the language menu of the panel.

Copies the list of menu entries from the panel.

Currently you can use this names to show to the user and see what languages are available. It uses a private property which works for Mac OS X 10.4 and 10.5.
For the language function you need the short names:

Australian Englishen_AU
British Englishen_GB
Canadian Englishen_CA
Deutschde
Englishen
Españoles
Françaisfr
Italianoit
MultilingualMultilingual
Nederlandsnl
Portuguêspt
Protuguês do Brasilpt_BR
Svenskasv

NSSpellCheckerMBS.learnWord(word as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.7 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Learns the given word.

Requires Mac OS X 10.5.

NSSpellCheckerMBS.menuForResult(TextCheckingResult as NSTextCheckingResultMBS, checkedString as string, options as Dictionary = nil, atLocation as NSPointMBS, view as NSViewMBS) as NSMenuMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 19.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
Provides a menu containing contextual menu items suitable for certain kinds of detected results.

TextCheckingResult: The NSTextCheckingResult instance for the checked string.
checkedString: The string that has been checked.
options: The options dictionary allows clients to pass in information associated with the document. See Spell Checking Option Dictionary Keys for possible key-value pairs.
location: The location, in the view’s coordinate system, to display the menu.
view: The view object over which to display the contextual menu.

Returns a menu suitable for displaying as a contextual menu, or adding to another contextual menu as a submenu.

NSSpellCheckerMBS.preventsAutocorrectionBeforeString(text as string, language as String = "") as Boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 19.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
In some cases the next typing should prevent a pending correction (if it is an @, for example).

This method allows clients to recognize these cases in a standardized way.

NSSpellCheckerMBS.recordResponse(response as Integer, correction as string, word as string, language as String = "")

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 19.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Records the user response to the correction indicator being displayed.

response: The user’s response. The possible values are shown in NSCorrectionResponse.
correction: The corrected word. This should match the original correction.
word: The original word. This should match the original correction.
language: The language being edited. This should match the original correction.

When a correction is automatically proposed, the user may respond in one of several ways. Clients may report this to the spell checker so that it can learn from the user's response and adjust future correction behavior accordingly.

Use of this method implies that the client stored the original word and original correction at least from the point at which the user accepts it until the user edits or reverts it.

NSSpellCheckerMBS.requestCandidatesForSelectedRange(selectedRange as NSRangeMBS, stringToCheck as string, types as Int64 = -1, options as Dictionary = nil, tag as Variant = nil) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 19.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Requests candidates in background.

NSSpellCheckerMBS.requestCheckingOfString(stringToCheck as string, range as NSRangeMBS, types as Int64 = -1, options as Dictionary = nil, tag as Variant = nil) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 19.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Requests that the string be checked in the background.

stringToCheck: The string to check.
range: The range of the string to check.
types: The type of checking to be performed. The possible constants are listed in NSTextCheckingType and can be combined using the C bit-wise OR operator to perform multiple checks at the same time.
options: The options dictionary specifying the types of checking to perform. See Spell Checking Option Dictionary Keys for the possible keys and expected values.
tag: An identifier unique within the application used to inform the spell checker which document that text is associated, potentially for many purposes, not necessarily just for ignored words. A value of 0 can be passed in for text not associated with a particular document.

The return value is a monotonically increasing sequence number that can be used to keep track of requests in flight.

Calls requestCheckingOfStringCompleted event later on main thread.

NSSpellCheckerMBS.setIgnoredWords(words() as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Sets the ignored word list.
Example
dim spell as NSSpellCheckerMBS // your spellchecker

dim f as FolderItem
dim t as TextInputStream
dim words(-1),line as string

f=SpecialFolder.Preferences.Child("SpellCheck RB.pref")
t=f.OpenAsTextFile
if t<>nil and spell<>nil then

while not t.eof
line=t.ReadLine(encodings.UTF8)
if line<>"" then
words.Append line
end if
wend

spell.setIgnoredWords words

end if

Some examples using this method:

NSSpellCheckerMBS.setLanguage(language as string) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Allows programmatic setting of the language to spell-check in.

Normally chosen by a pop-up-list in the spelling panel and defaulted to the user's preferred language, so call this with care.
Set to "" to use the language from the panel popup menu.

NSSpellCheckerMBS.spellingPanel as NSPanelMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop only
The spelling panel used for spell checking.

Some examples using this method:

NSSpellCheckerMBS.unlearnWord(word as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Tells the spell checker to unlearn a given word.

Available in Mac OS X v10.5 and later.
Same as the older forgetWord.

NSSpellCheckerMBS.updatePanels

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Updates the available panels to account for user changes.

This method should be called when a client changes some relevant setting, such as what kind of spelling, grammar checking, or substitutions it uses.

Available in Mac OS X v10.6 and later.

NSSpellCheckerMBS.updateSpellingPanelWithGrammarString(lang as string, detail as dictionary)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Specifies a grammar-analysis detail to highlight in the Spelling panel.

problemString: Problematic grammatical unit identified by checkGrammarOfString.
detail: One of the grammar-analysis details provided by checkGrammarOfString.

Available in Mac OS X v10.5 and later.

NSSpellCheckerMBS.updateSpellingPanelWithMisspelledWord(word as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 7.1 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Updates the panel with the word.

The checkSpellingOfString methods return the range of the misspelled word found. It is up to the client to select that word in their document and to cause the spelling panel to update itself to reflect the found misspelling. Clients can call updateSpellPanelWithMisspelledWord to insure that the spell panel is up to date.

Some examples using this method:

NSSpellCheckerMBS.userPreferredLanguages as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Provides a subset of the available languages to be used for spell checking.

Returns an array containing the user's preferred languages for spell checking. The order is set in the system preferences.

If automaticallyIdentifiesLanguages is true, then text checking will automatically use this method as appropriate; otherwise, it will use the language set by Language property.

The older checkSpellingOfString and checkGrammarOfString methods will use the language set by Language property, if they are called with an empty language argument.

Available in Mac OS X v10.6 and later.

NSSpellCheckerMBS.userQuotesArrayForLanguage(lang as string) as string()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the default values for quote replacement.
Example
dim n as new NSSpellCheckerMBS

dim en(-1) as string = n.userQuotesArrayForLanguage("en")

MsgBox Join(en," ")

An array of quote replacements used by the NSTextCheckingQuotesKey key-value pair.

Available in Mac OS X v10.6 and later.

NSSpellCheckerMBS.userReplacementsDictionary as dictionary

Type Topic Plugin Version macOS Windows Linux iOS Targets
method Spell Checking MBS MacCocoa Plugin 9.6 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
Returns the dictionary used when replacing words.

The key-value pairs in this dictionary are used by the NSTextCheckingQuotesKey when replacing characters and words.

Available in Mac OS X v10.6 and later.

NSSpellCheckerMBS.WordFieldValue as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
property Spell Checking MBS MacCocoa Plugin 11.3 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
The word textfield content string.

(Read and Write computed property)

Some examples using this property:

The items on this page are in the following plugins: MBS MacCocoa Plugin.


The biggest plugin in space...