Important: The information in this document is obsolete and should not be used for new development.
Inherits from | |
Package | com.apple.cocoa.application |
Companion guide |
The NSSpellChecker class gives any application an interface to the Cocoa spell-checking service. To handle all its spell checking, an application needs only one instance of NSSpellChecker. It provides a panel in which the user can specify decisions about words that are suspect.
The spell checker also offers the ability to provide word completions to augment the text completion system in Mac OS X version 10.3.
uniqueSpellDocumentTag
closeSpellDocumentWithTag
ignoreWord
setIgnoredWords
ignoredWords
setWordFieldStringValue
updateSpellingPanelWithMisspelledWord
completionsForPartialWordRange
Returns the NSSpellChecker (one per application).
public static NSSpellChecker sharedSpellChecker
()
Returns whether the application’s NSSpellChecker has already been created.
public static boolean sharedSpellCheckerExists
()
Returns a guaranteed unique tag to use as the spell-document tag for a document.
public static int uniqueSpellDocumentTag
()
Use this method to generate tags to avoid collisions with other objects that can be spell checked.
Returns the Spelling panel’s accessory NSView object.
public NSView accessoryView
()
Starts the search for a misspelled word in stringToCheck starting at startingOffset within the string object.
public NSRange checkSpellingOfString
(String stringToCheck, int startingOffset)
Returns the range of the first misspelled word. Wrapping occurs, but no ignored-words dictionary is used.
Notifies the receiver that the user has finished with the ignored-word document identified by tag, causing it to throw that dictionary away.
public void closeSpellDocumentWithTag
(int tag)
public NSArray completionsForPartialWordRange
(NSRange range, String string, String language, int tag)
Returns an array of strings from the spell checker dictionary representing complete words that the user might be trying to type, based off a partial word at the given range. Strings are returned in the order they should be presented. The language argument specifies the language used in the string. If language is null
, the current selection in the Spelling panel’s pop-up menu is used.
Returns the number of words in stringToCount.
public int countWordsInString
(String stringToCount, String language)
The language argument specifies the language used in the string. If language is null
, the current selection in the Spelling panel’s pop-up menu is used.
Returns an array of suggested spellings for the misspelled word word.
public NSArray guessesForWord
(String word)
If word contains all capital letters, or its first letter is capitalized, the suggested words are capitalized in the same way.
Returns the array of ignored words for a document identified by tag.
public NSArray ignoredWords
(int tag)
Invoke this method before closeSpellDocumentWithTag
if you want to store the ignored words.
Instructs the spell checker to ignore all future occurrences of wordToIgnore in the document identified by tag.
public void ignoreWord
(String wordToIgnore, int tag)
You should invoke this method from within your implementation of the NSIgnoreMisspelledWords interface’s ignoreSpelling
method.
Returns the current language used in spell checking.
public String language
()
Makes an NSView object an accessory of the Spelling panel by making it a subview of the panel’s content view.
public void setAccessoryView
(NSView aView)
This method posts a WindowDidResizeNotification
with the Spelling panel object to the default notification center.
Initializes the ignored-words document (a dictionary identified by tag with someWords), an array of words to ignore.
public void setIgnoredWords
(NSArray someWords, int tag)
Sets the language to use in spell checking to language.
public boolean setLanguage
(String language)
Returns whether the Language pop-up list in the Spelling panel lists language.
Sets the string that appears in the misspelled word field, using the string object aString.
public void setWordFieldStringValue
(String aString)
Returns the spell checker’s panel.
public NSPanel spellingPanel
()
Causes the spell checker to update the Spelling panel’s misspelled-word field to reflect word.
public void updateSpellingPanelWithMisspelledWord
(String word)
You are responsible for highlighting word in the document and for extracting it from the document using the range returned by checkSpellingOfString
. Pass the empty string as word to have the system beep, indicating no misspelled words were found.
© 1997, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-02-01)