Javascript: MisspelledWordCollection.getItemAtInputPosition Method
Description
Gets the misspelled word of the specified kind at the current text input position. If there is no misspelled word, the next possible word of is returned. If there is no misspelled word of the specified kind between the current input position and the end of the text, the first word of the specified kind is returned.
Syntax
<void> MisspelledWordCollection.getItemAtInputPosition(<MisspelledWordKind> kind, <RequestMisspelledWordCallback> callback, [<ErrorCallback> errorCallback])Parameters
| Parameter | Description |
|---|---|
| kind | Specifies the word's kind. |
| callback | Receives the misspelled word. |
| errorCallback | Optional. Is called when the operation failed with an error. |
Examples
The following example demonstrates MisspelledWordCollection.getItemAtInputPosition in a practical document-editing workflow. It gets the misspelled word of the specified kind at the current text input position. If there is no misspelled word, the next possible word of is returned. If there is no misspelled word of the specified kind between the current input position and the end of the text, the first word of the specified kind is returned.
function onTxError(error) {
console.error("TX Text Control error:", error.msg);
error.handled = true;
}
function inspectItemAtInputPosition(misspelledWords) {
misspelledWords.getItemAtInputPosition(
TXTextControl.MisspelledWordKind.All,
function(result) {
if (!result) {
console.warn("No misspelled word was returned.");
return;
}
console.log("get item at input position result:", result);
},
onTxError
);
}