HunSpell

General TRichView support forum. Please post your questions here
Post Reply
armagnac
Posts: 13
Joined: Tue Mar 05, 2024 8:35 am

HunSpell

Post by armagnac »

Hi,

I try to install this functionnality in my project.
I put on the form a RVAHunSpellInterface, a RVHunSpell, a RVAControlPanel and I affect properties.
When I run the program I get an error in

procedure TRVAHunSpellInterface.DoSpellFormLocalize(Sender: TRVHunSpell;
Form: TfrmRVCustomSpell_);
begin
LocalizeSpellForm(Form, FControlPanel);
end;

It seems the FControlPanel is nil, but I don't see where I can affect my RVAControlPanel into the TRVAHunSpellInterface : no property published, no procedure to set the RVAControlPanel as FControlPanel.

Thank you for your help
Sergey Tkachenko
Site Admin
Posts: 17997
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: HunSpell

Post by Sergey Tkachenko »

Do you call RVHunSpell.Check() yourself?
If you assigned RVHunSpell to RVAHunSpellInterface.HunSpell, you should not call RVHunSpell.Check() (because it will attempt to localize a spell-checking dialog and will fail).

Instead, use TrvActionSpellCheck action. This action assigns RVAHunSpellInterface.FControlPanel temporary while checking.

If you still need to call RVHunSpell.Check() yourself, assign RVAHunSpellInterface.HunSpell = nil, perform spelling checking, then restore.
armagnac
Posts: 13
Joined: Tue Mar 05, 2024 8:35 am

Re: HunSpell

Post by armagnac »

Hi, impossible to get a "normal" correction, always crash in LocalizeSpellForm because the parameter ControlPanel is nil.

Here the code into the OnCreate of the Form :

// --- 1) Configurer Hunspell ---
RVHunSpell1.DllDir := RepAppli;
RVHunSpell1.DllName := 'hunspell.dll';
RVHunSpell1.DictDir := RepAppli; // contient fr_toutesvarantes.aff et .dic
RVHunSpell1.SpellFormStyle := rvhfClassic;

// --- 2) Interface Hunspell ---
RVAHunSpellInterface1.HunSpell := RVHunSpell1;

// --- 3) SpellChecker ---
RVSpellChecker1.Language := 'fr';
RVSpellChecker1.SpellFormStyle := rvsfsClassic;

// --- 4) SpellInterface ---
RVSpellInterface1.SpellChecker := RVSpellChecker1;

// --- 5) Enregistrer l'éditeur ---
RVSpellChecker1.RegisterEditor(rve);

// --- 6) Activer le soulignement live ---
rve.LiveSpellingMode := rvlspOnChange;

// --- 7) Activer Hunspell à la fin ---
RVHunSpell1.Active := True;

and then the Correction.OnClick method :

RVSpellChecker1.Execute(rve);

What I do wrong ? Thank you
Sergey Tkachenko
Site Admin
Posts: 17997
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: HunSpell

Post by Sergey Tkachenko »

1) If you do not use RichViewActions, do not use RVAHunSpellInterface1. The form will be shown with default (English) messages.

2) If you use RichViewActions, create TRVAControlPanel component and assign RVAHunSpellInterface1 to its SpellInterface property.

The simplest solution: use TrvActionSpellingCheck action. Assign it to Correction.Action. The action automatically uses SpellInterface, you do not need to process Correction.OnClick.

Alternative solution: instead of RVSpellChecker1.Execute(rve), call RVAHunSpellInterface1.Check(rve, RVAControlPanel).
Post Reply