Can't seem to trun on Live Spelling.

General TRichView support forum. Please post your questions here
Post Reply
agent86
Posts: 59
Joined: Mon Jun 28, 2010 2:18 am
Location: San Francisco Bay Area, USA
Contact:

Can't seem to trun on Live Spelling.

Post by agent86 »

I am using a dbrichviewedit(rve). I moved code from the Simple Delphi Demo. I can spell check if I press the button but I can't seem to get Live Spelling to work. I cut and pasted the Addict Spelling components for TrichView from the Simple Delphi Demo and have compared and the set up looks the same.

I have moved the dictionaries to the application directory.

I turn it on in the FormCreate procedure.

procedure TReportWriterMainForm.FormCreate(Sender: TObject);
begin
// Filling font names combobox
cmbFont.Items.Assign(Screen.Fonts);
New;

FontName := 'Times New Roman'; //cmbFont.Items[cmbFont.ItemIndex];
rve.ApplyStyleConversion(TEXT_APPLYFONTNAME);

rve.Format ;
rve.StartLiveSpelling ;
PopupMenu1.AutoHotkeys := maManual;

end;
agent86
Posts: 59
Joined: Mon Jun 28, 2010 2:18 am
Location: San Francisco Bay Area, USA
Contact:

AutoCorrect doesn't work either...

Post by agent86 »

What information do you need from me to help me diagnose these problems. I've compared the code and can't find the problem. I renamed the RichviewEdit in the Simple Demo to match my dbrichviewedit name(rve) to test and it works fine. I thought I was missing some component name in the procedures. Apparently knot as it all works fine in the Simple Demo.

// Spelling dialog
procedure TReportWriterMainForm.SpellCheckSpeedButtonClick(
Sender: TObject);
begin
RVAddictSpell31.CheckRichViewEdit(rve, ctSmart);
end;
{------------------------------------------------------------------------------}
// Live spelling
procedure TReportWriterMainForm.rveSpellingCheck(Sender: TCustomRichView;
const AWord: String; StyleNo: Integer; var Misspelled: Boolean);
begin
Misspelled := not RVAddictSpell31.WordAcceptable(AWord);
end;
{------------------------------------------------------------------------------}
// Ignore All
procedure TReportWriterMainForm.RVAddictSpell31ParserIgnoreWord(Sender: TObject;
Before: Boolean; State: Integer);
begin
if not Before and (State in [IgnoreState_IgnoreAll, IgnoreState_Add]) then
rve.LiveSpellingValidateWord(RVAddictSpell31.CurrentWord);
end;
{------------------------------------------------------------------------------}
// Before displaying the popup menu, we fill it with suggestions for the
// misspelled word. The clicked misspelled word is selected
// (alternatively, you can select it immediately before the replacement
// in PopupMenuItemClick)
procedure TReportWriterMainForm.PopupMenu1Popup(Sender: TObject);
var wrd: String;
stl, i: Integer;
sl: TStringList;
mi: TMenuItem;
begin
while PopupMenu1.Items.Count>0 do
PopupMenu1.Items[0].Free;

if rve.GetCurrentMisspelling(True, wrd, stl) then
begin
sl := TStringList.Create;
RVAddictSpell31.Suggest(wrd, sl);

for i := 0 to sl.Count-1 do
begin
mi := TMenuItem.Create(PopupMenu1);
mi.Caption := sl;
mi.OnClick := PopupMenuItemClick;
PopupMenu1.Items.Add(mi);
end;

if sl.Count=0 then
begin
mi := TMenuItem.Create(PopupMenu1);
mi.Caption := '(no suggestions)';
mi.Enabled := False;
PopupMenu1.Items.Add(mi);
end;

mi := TMenuItem.Create(PopupMenu1);
mi.Caption := '-';
PopupMenu1.Items.Add(mi);

mi := TMenuItem.Create(PopupMenu1);
mi.Caption := '&Add to Dictionary';
mi.OnClick := PopupMenuAddToDictionaryClick;
PopupMenu1.Items.Add(mi);

mi := TMenuItem.Create(PopupMenu1);
mi.Caption := '&Ignore All';
mi.OnClick := PopupMenuIgnoreAllClick;
PopupMenu1.Items.Add(mi);

sl.Free;
end;
end;
{------------------------------------------------------------------------------}
// Clicking menu item - menu caption replaces the selected text
procedure TReportWriterMainForm.PopupMenuItemClick(Sender: TObject);
begin
{
The text is already selected in PopupMenu1Popup by calling
GetCurrentMisspelling(True,...).
If you do not want to select misspelled word when displaing the menu,
call GetCurrentMisspelling(False,...) there, and call
GetCurrentMisspelling(True,...) here.
The same is for other PopupMenu*** procedures.
}
rve.InsertText((Sender as TMenuItem).Caption);
end;
{------------------------------------------------------------------------------}
// Clicking "Add to Dictionary"
procedure TReportWriterMainForm.PopupMenuAddToDictionaryClick(Sender: TObject);
var s: String;
begin
s := rve.GetSelText;
RVAddictSpell31.AddToDictionary(s);
rve.LiveSpellingValidateWord(s);
end;
{------------------------------------------------------------------------------}
// Clicking "Ignore All"
procedure TReportWriterMainForm.PopupMenuIgnoreAllClick(Sender: TObject);
var s: String;
begin
s := rve.GetSelText;
RVAddictSpell31.AddToIgnoreList(s);
rve.LiveSpellingValidateWord(s);
end;

{------------------------------------------------------------------------------}
// Autocorrection procedure. You can copy it in your application
function AutoCorrect(rvee: TCustomRichViewEdit; rvad3: TRVAddictSpell3): Boolean;
var ItemNo, WordEnd, WordStart: Integer;
s,s2: String;
{$IFNDEF RVUNICODESTR} // <- Defined for Delphi 2009+
CodePage: TRVCodePage;
{$ENDIF}
begin
Result := False;
rvee := rvee.TopLevelEditor;
ItemNo := rvee.CurItemNo;
WordEnd := rvee.OffsetInCurItem;
{$IFNDEF RVUNICODESTR}
CodePage := rvee.RVData.GetItemCodePage(ItemNo);
{$ENDIF}
if (rvee.GetItemStyle(ItemNo)<0) or
(rvee.Style.TextStyles[rvee.GetItemStyle(ItemNo)].Charset=SYMBOL_CHARSET) then
exit;
s := rvee.GetItemText(ItemNo);
WordStart := WordEnd;
if WordStart<1 then
exit;
while (WordStart-1>0) and not
{$IFDEF RVUNICODESTR}
rvee.RVData.IsDelimiterW(s[WordStart-1])
{$ELSE}
rvee.RVData.IsDelimiterA(s[WordStart-1], CodePage)
{$ENDIF}
do
dec(WordStart);
s := Copy(s, WordStart, WordEnd-WordStart);
Result := rvad3.WordHasCorrection(s,s2);
if Result then
begin
rvee.SetSelectionBounds(ItemNo, WordStart, ItemNo, WordEnd);
rvee.InsertText(s2);
end;
end;
{------------------------------------------------------------------------------}
// autocorrection on typing: make sure that autocorrect.adu is installed and
// checked in the options dialog
procedure TReportWriterMainForm.rveKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key in [VK_SPACE, VK_RETURN, VK_TAB] then
AutoCorrect(rve, RVAddictSpell31);
end;

{------------------------------------------------------------------------------}
// Double click to show thesaurus
procedure TReportWriterMainForm.rveRVDblClick(Sender: TCustomRichView;
ClickedWord: TRVRawByteString; Style: Integer);
begin
RVThesaurus31.LookupRichViewEdit(rve);
end;

////////////////////////////////////////////////////////////////////////////////
// end Spell checker //
////////////////////////////////////////////////////////////////////////////////
agent86
Posts: 59
Joined: Mon Jun 28, 2010 2:18 am
Location: San Francisco Bay Area, USA
Contact:

Found the problem...boy do I feel dumb!

Post by agent86 »

Boy do I feel dumb.

I had forgotton to connect the procedures to their events.

Everthing seems to be working now.
Post Reply