Category / Section
How to display the intelisense popup when special character is pressed in EditControl?
2 mins read
You can display the intellisense popup, while pressing the special characters in EditControl. This requirement can be achieved by configuring, custom language using ConfigLexem in EditControl.
The following code example demonstrates the same.
C#
// Creates format for methods coloring. ISnippetFormat formatMethod = editControl1.Language.Add("Method", "Text"); formatMethod.FontColor = Color.HotPink; // Creates format for properties coloring. ISnippetFormat formatProperty = editControl1.Language.Add("Property", "Text"); formatProperty.FontColor = Color.Goldenrod; // Disables ContextChoiceList dropping after . in global context. ConfigLexem lexemDot = GetConfigLexem((IConfigLexem)editControl1.Language, "."); lexemDot.DropContextChoiceList = false; // Adds "<?" word processing for global context. ConfigLexem lexemId = GetConfigLexem((IConfigLexem)editControl1.Language, "<"); lexemId.Type = FormatType.Text; // "<?" starts it`s own context. It does not have EndBlock specified, so the first unprocessed token will force parser to exit from "this"'s context. lexemId.IsComplex = true; ConfigLexem lexemQues = GetConfigLexem((IConfigLexem)lexemId, "?"); lexemQues.Type = FormatType.Operator; // "?" can drop context choice list lexemQues.DropContextChoiceList = true; lexemQues.IsComplex = true; ConfigLexem this_Property3 = GetConfigLexem((IConfigLexem)lexemQues, "php..>"); this_Property3.Type = FormatType.Custom; this_Property3.FormatName = "Property"; this_Property3.IsComplex = true; // Add "GenerateMap" configuration after "this." ConfigLexem this_Method2 = GetConfigLexem((IConfigLexem)lexemQues, " text..>"); this_Method2.Type = FormatType.Custom; this_Method2.FormatName = "Method"; // needed for processing "(" and ")" next. this_Method2.IsComplex = true; //To reset the cached data. editControl1.Language.ResetCaches();
VB
' Creates format for methods coloring. Dim formatMethod As ISnippetFormat = editControl1.Language.Add("Method", "Text") formatMethod.FontColor = Color.HotPink ' Creates format for properties coloring. Dim formatProperty As ISnippetFormat = editControl1.Language.Add("Property", "Text") formatProperty.FontColor = Color.Goldenrod ' Disables ContextChoiceList dropping after . in global context. Dim lexemDot As ConfigLexem = GetConfigLexem(CType(editControl1.Language, IConfigLexem), ".") lexemDot.DropContextChoiceList = False ' Adds "<?" word processing for global context. Dim lexemId As ConfigLexem = GetConfigLexem(CType(editControl1.Language, IConfigLexem), "<") lexemId.Type = FormatType.Text ' "<?" starts it`s own context. It does not have EndBlock specified, so the first unprocessed token will force parser to exit from "this"'s context. lexemId.IsComplex = True Dim lexemQues As ConfigLexem = GetConfigLexem(CType(lexemId, IConfigLexem), "?") lexemQues.Type = FormatType.Operator ' "?" can drop context choice list lexemQues.DropContextChoiceList = True lexemQues.IsComplex = True Dim this_Property3 As ConfigLexem = GetConfigLexem(CType(lexemQues, IConfigLexem), "php..>") this_Property3.Type = FormatType.Custom this_Property3.FormatName = "Property" this_Property3.IsComplex = True ' Add "GenerateMap" configuration after "this." Dim this_Method2 As ConfigLexem = GetConfigLexem(CType(lexemQues, IConfigLexem), " text..>") this_Method2.Type = FormatType.Custom this_Method2.FormatName = "Method" ' needed for processing "(" and ")" next. this_Method2.IsComplex = True 'To reset the cached data. editControl1.Language.ResetCaches()
Note:
The function named “ResetCaches” is must be called after every change of the configuration inside the language.
Figure 1: Context prompt list is shows when pressing the “?“ in EditControl.
Sample Links: