Question

I am using ScintillaNET to make a basic IntelliSense editor. However, I have a problem when I call _editor.CallTip.Show("random text") in the AutoCompleteAccepted Event.

If I type pr for example, and scroll and select printf in the drop-down list, it goes to my AutoCompleteAccepted event and when I call the CallTip.Show, the rest of the word does not get added (however, without that CallTip code, the rest of the word is filled).

So, if I typed pr then it stays pr and I get my CallTip. How do I make sure the rest of the word gets inserted AND the CallTip shows?

Is the AutoCompleteAccepted Event not the right place to call it? If so, where should I call the CallTip.Show so that it works side-by-side with my AutoComplete?

Was it helpful?

Solution

Finally figured it out! The AutoCompleteAccepted Event isn't the right place to put CallTip.Show

What is going on is the fact that when AutoCompleteAccepted Event is called and you add text to the ScintillaNET control, it takes time for the UI to update and so, when you call to show the CallTip, it interferes with the text being inserted into the control.

The better way to do it is to call CallTip.Show in the TextChanged event, as they you know that the text has been inserted when the AutoCompleteAccepted Event was called.

It would now look something like this:

String calltipText = null; //start out with null calltip

...

private void Editor_TextChanged(object sender, EventArgs e)
{
    if (calltipText != null)
    {
         CallTip.Show(calltipText); //note, you may want to assign a position
         calltipText = null; //reset string
    }

    ... 
}

...

private void Editor_AutoCompleteAccepted(object sender, AutoCompleteAcceptedEventArgs e)
{
    if (e.Text == "someThing")
    {
         /* Code to add text to control */
         ... 

         calltipText = "someKindOFText"; //assign value to calltipText
    }

}

That is essentially what can be done to ensure the AutoComplete fills correctly and you get the CallTip to show.

Just note, that the CallTip MAY end up in unintended places, so it is recommended to set the value of where you want the CallTip to show up

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top