ScintillaNET icon indicating copy to clipboard operation
ScintillaNET copied to clipboard

Disable highight when no selection

Open arnovb-github opened this issue 6 years ago • 5 comments

Not really an issue I suppose, but I cannot find where to set this option:

When I click a word, it and all other occurrences are highlighted. I do not want that when I just click the word, I only want it when I select the word (like in Notepad++). What setting to use to control that behavior?

arnovb-github avatar Mar 30 '19 15:03 arnovb-github

? It doesn't do that by default. Where do you execute the code to highlight the "word"?

tobeypeters avatar Mar 30 '19 16:03 tobeypeters

I don't, it is the default behaviour in the ScintillaNet.WPF project I am basing my solution on, but I cannot seem to find which setting to change.

arnovb-github avatar Mar 30 '19 19:03 arnovb-github

** Update:**

I decided to look more. In DocumentForm.xaml.cs, you can comment out the code in Scintilla_MouseDown():

        private void Scintilla_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            //{
            //    switch (e.Button)
            //    {
            //        case System.Windows.Forms.MouseButtons.Left:
            //            if (FindReplace == null) break;

            //            //Clear current highlights
            //            FindReplace.ClearAllHighlights();

            //            //Highlight identical text
            //            string sWord = Scintilla.GetWordFromPosition(Scintilla.CurrentPosition);
            //            if (!string.IsNullOrEmpty(sWord))
            //                FindReplace.FindAll(sWord, false, true);

            //            break;

            //        default:
            //            break;
            //    }
            //}
        }

tobeypeters avatar Mar 30 '19 20:03 tobeypeters

Thank youI Wouln't have thought of looking into the integration with FindReplace stuff. This puts me on the right track, issue can be closed. Note that I was actually wrong to put the issue here, as it really was with FindReplace.

arnovb-github avatar Mar 31 '19 01:03 arnovb-github

I added it to my ScintillaNet Winform project. Eventually, I'll post the whole Editor class, which has comment/uncomment, custom csyntax highlighter, keyword loading from JSON file, auto indent, printing, etc ... I've got to enhance everything, add default params, add document management. We'll see what else.

                private bool HighlightWords; //Just define anywhere in your class

                Click += (s, e) => 
                {
                    if (HighlightWords) { findReplace.ClearAllHighlights(); HighlightWords = false; }
                    findReplace.ClearAllHighlights();
                };

                DoubleClick += (s, e) =>
                {
                    string sWord = GetWordFromPosition(CurrentPosition);
                    if (sWord != "") { findReplace.FindAll(sWord, false, true); HighlightWords = true; }
                };

tobeypeters avatar Apr 03 '19 16:04 tobeypeters