OK, everything is working except selecting the first item in the list. On the first character, the item in the member list is selected. Example: I type 'i' and get a list with "if", "in", "integer", "interrupt" and "if" is selected. When I type the second character, 'n', the list is filtered and only "in", "integer", "interrupt" are displayed, but there is no selected item.
Here is my code:
public override bool ShowIntelliPromptMemberList(SyntaxEditor syntaxEditor)
{
return ShowIntellipromtMemberList(syntaxEditor, false);
}
private bool ShowIntellipromtMemberList(SyntaxEditor syntaxEditor, Boolean completeWord)
{
SemanticParserService.WaitForParse(SemanticParserServiceRequest.GetParseHashKey(syntaxEditor.Document, syntaxEditor.Document));
// Initialize the member list
IntelliPromptMemberList memberList = syntaxEditor.IntelliPrompt.MemberList;
memberList.ResetAllowedCharacters();
memberList.Clear();
memberList.ImageList = SyntaxEditor.ReflectionImageList;
// Get the target text range
TextRange targetTextRange = TextRange.Deleted;
TextStream stream = syntaxEditor.Document.GetTextStream(syntaxEditor.Caret.Offset);
if (stream.IsAtTokenStart)
{
if (stream.Offset > 0)
{
stream.GoToPreviousToken();
targetTextRange = stream.Token.TextRange;
}
}
else
{
stream.GoToCurrentTokenStart();
targetTextRange = stream.Token.TextRange;
}
// Get the member list items and add keywords
IconResource icon = IconResource.Keyword;
foreach (String s in this.myReservedWords.Keys)
{
if (s.StartsWith(syntaxEditor.Document.GetTokenText(stream.Token)))
{
IntelliPromptMemberListItem item = new IntelliPromptMemberListItem(s, (int)icon);
memberList.Add(item);
}
}
// Show the list
if (memberList.Count > 0)
{
if (completeWord)
memberList.CompleteWord(targetTextRange.StartOffset, targetTextRange.Length);
else
memberList.Show(targetTextRange.StartOffset, targetTextRange.Length);
return true;
}
return false;
}
protected override void OnSyntaxEditorKeyTyped(SyntaxEditor syntaxEditor, KeyTypedEventArgs e)
{
if (Char.IsLetter(e.KeyChar))
ShowIntelliPromptMemberList(syntaxEditor);
}
It appears that the targetTextRange is correct.
This behavior occurs on the second character TYPED. If the 'i' was already in the text and I place my insertion point behind it and type 'n', then the "in" element in the list is selected - but when I type 't', there is no selected item. I must be missing some step of telling the editor something.
Thanks.