LMD-Tools SpellPack Guide


Full Spelling Check


LMD SpellPack provides TLMDSpellScanDialog component for performing full spell check. The dialog allows organizing full top-down spelling check of the text inside a control or several controls at ones. Handling of several text controls is useful for checking data correctness on the data entry forms with usually contains several text fields.

 

Unlike most other Delphi's dialogs TLMDSpellScanDialog component uses asynchronous event based API, which does not block application UI and allow user to move caret and edit text freely. This means that dialog's Execute method only initiates spell checking process, and it continues asynchronously with every user action, such as error skipping or replacement with suggested word, as will be described below.

 

Since modeless floating window seems to be an outdated concept the dialog provides no built-in UI. Instead it relies on API methods and events which can be used by custom application's UI.

 

Dialog API

 

Dialog's Execute method initiates spell checking process. There several overloaded version of the method, including versions which allow to specify checked control or array of controls. The version of Execute method without parameters is supposed for advanced use together with OnNextControl event.

 

Execute methods initiates full spell checking process, searches and selects first spell error, if any and returns control to application's code. If there no spell errors in specified controls, Execute method will return False.

 

At any given point in time Active property can be used retrieve the state of spell checking process. Also, Cancel method can be called to cancel currently active process.

 

In active dialog state Skip or Replace methods can be called to handle current spell error and move caret to the next error (if any):

 

Skip

Leaves the current error as is; then moves the caret to the next error in the same or next control.

Replace

Replace current error text with specified AWord string; then moves the caret to the next error in the same or next control. The list of possible replacements for current spell error can be retrieved using Suggest method.

 

Every time the state of the dialog is changed, OnChange event is fired. Application code should use the event to update UI state. This happens in any of the following cases:

 

Execute

Method is called and there is at least single spell error.

Cancel

Method is called in Active state.

Skip or Replace

Methods are called and there is a next spell error.


User moves edit caret, selects text, or moves focus between controls.

 

Delay property can be specified at design-time to include some small delay in time between real state change and OnChange event fire. This allow to prevent UI freezing, in case of frequent user's actions, such as text editing or selection via keyboard or mouse, because Suggest method, usually used in UI updating code is quite slow.

 

If Execute, Skip or Replace methods cannot find next error, OnFinished event is fired. It also fired in case of Cancel method call. The event provides ACanceled parameter, and should also be used to update application UI state.

 

Control property provides access to currently focused control, if any. IsOnError property indicates, whether the cared in focused control is placed on spell error currently. If yes, then ErrorText specifies current error text.

 

Dialog UI

 

As has been noted above, LMD SpellPack does not provide built-in UI for full spell checking. Please refer to demos to learn how potential UI can look, and how to use TLMDSpellScanDialog API.

 

clip0008

 

Generally, application should use the following dialog features:

 

Execute, Cancel, Skip and Replace

Methods to control spell checking process.

OnChange and OnFinished

Events to update spelling related UI.

Active, Control, IsOnError, ErrorText

Properties and Suggest method to get UI related information about current dialog state.