Menu mSpell

The menu format "mSpell" contains the public procedures for use from other libraries. It also contains the menu driven options "Check Window", "Check Current Field" and "Options".

The public procedures of the format are as follows.

CheckTopWindow ()

This procedure will check all fields in the top most window (the menu option "Check Window" calls this procedure). CheckTopWindow will identify the top window and call procedure CheckWindow passing it the reference of the top window. Once the window has been checked, CheckTopWindow calls procedure EndSpell to tidy up, i.e. close the spell checker window if it has been opened.

CheckCurrentField ()

CheckCurrentField will check the current field of the top most window. It calls procedure CheckField, passing it the reference to the field which was specified by the last call to FieldChanged, telling it to check selected text if there is any (the menu option "Check Current Field" calls this procedure). Once the current field has been checked, CheckCurrentField calls procedure EndSpell to tidy up, i.e. close the spell checker window if it has been opened.

CheckWindow ( pWindowRef )

Checks all fields on the window pWindowRef. It determines if a field can be checked by calling the procedure CanSpellField in your window.

NOTE: CheckWindow will not call procedure EndSpell. You must call this procedure when the spell check is complete, if you have called CheckWindow directly.

CheckField ( pObjRef[, pSelection] )

Checks the text of the field pObjRef. If pSelection is kTrue and the field has selected text, it will only check the selection. CheckField will call your procedure GetSpellData to fetch the text and selection range. The selection is resynchronised if words are replaced. CheckField calls procedure CheckData to check the contents of the field. Once the text has been corrected, CheckField will call procedure SetSpellData of the window containing the field.

Unless you have specified your own caption (see SetCaption), CheckField calculates an appropriate caption for the spell checker window, based on the object name of the field. Underscores within the object name are replaced with spaces.

NOTE: CheckField will not call procedure EndSpell. You must call this procedure when the spell check is complete, if you have called CheckField directly.

CheckData ( pData )

Checks the data specified by the field name parameter pData. The result is returned in pData. CheckData will also initialise the error handler (procedure mSpell/ErrorHandler in the spell library). The default error handler procedure will cancel the current session if an error occurs.

NOTE: CheckData will not call procedure EndSpell. You must call this procedure when the spell check is complete, if you have called CheckData directly.

EndSpell ()

Must be called at the end of the spell check session. EndSpell will display an OK message if the session has not been cancelled by the user, close the spell checker window if it has been opened, and clear the modified and cancelled flags and the error handler procedure. Additionally, EndSpell clears the custom caption if it has been set, see SetCaption.

NOTE: EndSpell is called by the procedures CheckTopWindow and CheckCurrentField, so there is no need to call EndSpell your self, if these procedures have been used.

SetCaption ( pCaption )

By default the spell checker window will display appropriate captions which are calculated by procedure CheckField. The captions are calculated by retrieving the object name of the field being checked. You can specify your own captions by calling this procedure prior to calling procedure CheckField or any other procedure which calls CheckField. Note: Custom captions are cleared by procedure EndSpell.

Modified ([ pClear ])

Returns the modified state of the current spell check session. You can call this procedure prior to calling EndSpell, to test if the text being checked has changed. The modified flag is cleared on return. If you do not want it to be cleared, you must pass kFalse for the pClear parameter.

Cancelled ([ pClear ])

Returns the cancelled state of the current spell check session. You can call this procedure prior to calling EndSpell, to test if the user has cancelled the session. The cancelled flag is cleared on return. If you do not want it to be cleared, you must pass kFalse for the pClear parameter.

WindowChanged ( pWindow )

You call WindowChanged when your top window has changed or is about to change. If the window coming to the top supports spell checking, you must pass an item reference of the window in pWindow. Otherwise you should pass #NULL. See Integrating The Library.

FieldChanged ( pField )

You call FieldChanged when the current field changes and the new current field supports spell checking, or the old current field supports it but the new one doesn’t. The simplest solution is to only act on #BEFORE and #AFTER messages of fields which support spell checking. Call FieldChanged with the item reference of the field during a #BEFORE message, and with #NULL during an #AFTER. See  Integrating The Library.

CanSpellWindow()

Returns the current enabled state of the menu option "Check Window".

CanSpellField()

Returns the current enabled state of the menu option "Check Current Field".