trichview.com

trichview.support




Re: Auto Spell Correction


Return to index


Author

Message

Sergey Tkachenko

Posted: 09/10/2004 10:27:25


You need to process OnKeyDown, and replace words when user presses space or

enter:


if Key in [VK_SPACE, VK_RETURN] then begin

      RVA_Addict3AutoCorrect(RichViewEdit1);



RVA_Addict3AutoCorrect is defined in RichViewActions (RichViewActions.pas),

but it can be copied from them and used separately, just add TRVAddictSpell3

parameter:


function RVA_Addict3AutoCorrect(rve: TCustomRichViewEdit; RVA_Addict3:

TRVAddictSpell3): Boolean;

var ItemNo, WordEnd, WordStart: Integer;

    s,s2: String;

begin

  Result := RVA_Addict3<>nil;

  if not Result then

    exit;

  rve := rve.TopLevelEditor;

  ItemNo := rve.CurItemNo;

  WordEnd := rve.OffsetInCurItem;

  if (rve.GetItemStyle(ItemNo)<0) or

    (rve.Style.TextStyles[rve.GetItemStyle(ItemNo)].Charset=SYMBOL_CHARSET)

then

    exit;

  s := rve.GetItemTextA(ItemNo);

  WordStart := WordEnd;

  if WordStart<1 then

    exit;

  while (WordStart-1>0) and not rve.RVData.IsDelimiterA(s[WordStart-1]) do

    dec(WordStart);

  s := Copy(s, WordStart, WordEnd-WordStart);

  Result := RVA_Addict3.WordHasCorrection(s,s2);

  if Result then begin

    rve.SetSelectionBounds(ItemNo, WordStart, ItemNo, WordEnd);

    rve.InsertText(s2);

  end;

end;



>

> procedure TfrmCSNDTextEditor.rveEditorSpellingCheck(

>   Sender: TCustomRichView; const AWord: String; StyleNo: Integer;

>   var Misspelled: Boolean);

> begin

>   inherited;

>   Misspelled := not rvasSpellCheckEditor.WordAcceptable(AWord);

> end;

>

> But the auto correction still doesn't work even though the option has been

> set to true in Addict Spell Check option. Any extra thing that I need to

do

> in this event in order to support auto correction?

>

> Does anyone can help me to answer this question?

>

>





Powered by ABC Amber Outlook Express Converter