Title Back Colour Keyoti Title Line Title Curve
Blue Box Top

Regarding Double Space as a Spelling Error - RapidSpell Desktop .NET - Forum

Welcome Guest Search | Active Topics | Log In | Register

Options
jppx1967
#1 Posted : Tuesday, March 18, 2014 10:44:29 AM
Rank: Member

Groups: Registered

Joined: 3/18/2014
Posts: 2
Hi. Does anyone have experience of forcing the component to treat double space (ie. two space chars together) as a spelling error ?
harry
#2 Posted : Wednesday, March 19, 2014 4:43:33 AM
Rank: Member

Groups: Registered

Joined: 4/22/2006
Posts: 216
Hi, yes here's how to approach it. Add this subclass

Code:

class CustomRapidSpellChecker : RapidSpellChecker
    {
        protected override bool IsWord(int wordStart, int wordEnd)
        {

            if (!base.IsWord(wordStart, wordEnd))
            {
                //see if its actually multiple spaces
                if (wordEnd - wordStart > 1 && theText.ToString(wordStart, wordEnd - wordStart).Contains("  "))
                    return true;//yes we want it treated like a word
                else
                    return false;

            }
            else return true;
        }

        protected override bool LookUpMainDictionary(string query)
        {
            return base.LookUpMainDictionary(query) && !query.Contains("  ");
        }

        protected override ArrayList FindSuggestions(string word, bool searchLowerCase)
        {
            if (word.Contains("  ")) return new ArrayList(new string[1] { " " });
            else
                return base.FindSuggestions(word, searchLowerCase);
        }
    }


and then hook it up like this

Code:

rapidSpellAsYouType1.RapidSpellChecker = new CustomRapidSpellChecker();


I didn't try it but usage with RapidSpellDialog should just be

rapidSpellDialog1.CheckerEngine = new CustomRapidSpellChecker();

It may need a little refinement, for example it will suggest " " as a correction for a string like " ." - so you could modify FindSuggestions to be a bit smarter than the code I've given.

The one thing that isn't so great about it is that the suggestion item will be a " ", so it doesn't look like much to the user. One solution would be to delete the FindSuggestions override and then no suggestion is shown - and the user hopefully can see for themselves what the problem is.

-Harry
-Harry
jppx1967
#3 Posted : Wednesday, March 19, 2014 9:52:41 AM
Rank: Member

Groups: Registered

Joined: 3/18/2014
Posts: 2
Thanks Harry - That worked perfectly.
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.




About | Contact | Site Map | Privacy Policy

Copyright © 2002- Keyoti Inc.