Hello All:
I have a live spell check problem that I have been unable to figure out.
Using the RichViewEdit, and an RVAPopupMenu. Also using EDDSSpell and the TrvSpellDialog to make that work. I can spell check OK when doing the whole document. The live spell check works OK - a misspelled word gets a wavy line under it correctly (through the use of the OnSpellingCheck event). My problem is trying to allow the user to change the word through the right-click popup menu when it is spelled wrong or not found. I can force suggestions to be added to the standard right popup menu by physically adding items to the string list in the RvaPopupMenu.OnLiveSpellGetSuggestions() event (see below:)
procedure TfrmEditor.RVAPopupMenu1LiveSpellGetSuggestions(
Sender: TRVAPopupMenu; Edit: TCustomRichViewEdit; const Word: String;
StyleNo: Integer; Suggestions: TStrings);
Var
SList: TStrings;
begin
Suggestions.Add('Froop');
Suggestions.Add('Gleep');
end;
What I cannot do, however, is to get the RVEDSSSpell dialog to give me suggestions from the dictionary. I mean, It works fine if I just put a button on the dialog and press it - then I get all of the correct suggestions. Inside the method called in the OnLiveSpellGetSuggestions event, the call to RVEDSSPell.SuggestWords() just does not work - it always returns a NIL string list.
Is this caused by the spelling thread working at a lower priority?
Ideally, I would like to be able to put up the same spelling dialog that it uses when spell checking the entire control when a word is incorrect; allowing add / ignore / etc. If it puts up this dialog, I would like to avoid the standard pop up with the cut, copy, paste, etc on it. I am not sure how to do this.
Ideas?
Thanks
jamie
Live Spell Check Problem
More information
The base code that I am working with corresponds to the demo, ActionTest. Therefore, when I right mouse click while the cursor is on a correctly spelled word, I get a context menu that is surfaced through RVAPopupMenu1. It contains items including Cut, Copy, Paste, Font, Paragraph, etc. I am handling the SpellingCheck event with the following code:
Misspelled := frmMain.dlgSpell.IsBadWord(AWord);
This gives me the wavy red line when the word is spelled bad. When the word is misspelled and I write click on it, an OnLiveSpellGetSuggestions event is generated. Here is where I am having problems. The following code does not work in this event, even though it works fine when called from a simple pushbutton is pressed:
Suggestions := frmMain.dlgSpell.SuggestWords(Word, 8 );
Tracing down the EDDSSpell code, it is actually serching through the dictionary, but no values are ever returned. Again, exactly the same code does work correctly if executed based on a button click.
My guess is I do not understand the chain of events that are supposed to happen. For example, if I force in a few items (as if they were returned by the SuggestedWords()), I see them in the popup menu, and if I click on one, the highlighted word is replaced by it. However, if I do not understand how to deal with it if I choose to ignore that word. Nor can I figure out how I would add it (at this time) to the dictionary.
Are there any examples / demos that deal with the RichView and live spell check?
Misspelled := frmMain.dlgSpell.IsBadWord(AWord);
This gives me the wavy red line when the word is spelled bad. When the word is misspelled and I write click on it, an OnLiveSpellGetSuggestions event is generated. Here is where I am having problems. The following code does not work in this event, even though it works fine when called from a simple pushbutton is pressed:
Suggestions := frmMain.dlgSpell.SuggestWords(Word, 8 );
Tracing down the EDDSSpell code, it is actually serching through the dictionary, but no values are ever returned. Again, exactly the same code does work correctly if executed based on a button click.
My guess is I do not understand the chain of events that are supposed to happen. For example, if I force in a few items (as if they were returned by the SuggestedWords()), I see them in the popup menu, and if I click on one, the highlighted word is replaced by it. However, if I do not understand how to deal with it if I choose to ignore that word. Nor can I figure out how I would add it (at this time) to the dictionary.
Are there any examples / demos that deal with the RichView and live spell check?
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
In the TRVAPopupMenu's event, Suggestions is not a VAR-parameter.
Assignment to it does nothing, you should add strings to it instead:
I uploaded a demo to
http://www.trichview.com/resources/spell/rvedsspell.zip
Assignment to it does nothing, you should add strings to it instead:
Code: Select all
procedure TForm1.RVAPopupMenu1LiveSpellGetSuggestions(
Sender: TRVAPopupMenu; Edit: TCustomRichViewEdit; const Word: String;
StyleNo: Integer; Suggestions: TStrings);
var sl: TStringList;
begin
sl := RVSpellDlg1.SuggestWords(Word, 8);
try
Suggestions.Assign(sl);
finally
sl.Free;
end;
end;
http://www.trichview.com/resources/spell/rvedsspell.zip