Intellisense member list during snippet expansion

SyntaxEditor for Windows Forms Forum

Posted 17 years ago by Jeff Cohen
Avatar
I've created a few simple snippets and they work great inside the editor. My snippets tend to be pretty simple - the user usually can fill in one or two fields.

Sometimes I need to show a list of possible choices for one of the fields in addition to accepting arbitrary text. So I thought I would pop an intellisense member list when the field activates, like this:

        void editor_CodeSnippetFieldActivated(object sender, CodeSnippetFieldEventArgs e)
        {
            editor.IntelliPrompt.DropShadowEnabled = true;
            editor.IntelliPrompt.MemberList.Clear();
            editor.IntelliPrompt.MemberList.Add(new IntelliPromptMemberListItem("one", 0));
            editor.IntelliPrompt.MemberList.Add(new IntelliPromptMemberListItem("two", 0));
            editor.IntelliPrompt.MemberList.Add(new IntelliPromptMemberListItem("three", 0));
            editor.IntelliPrompt.MemberList.Show();
        }
But a couple of unexpected things happen:

1. When I select an item in the member list, it is appended to the default value to the field, when I need it to replace the default value instead. So if my default value for a field is defined in the snippet as "size", and then I pick "two" from the intellisense list, the field value becomes "sizetwo" instead of "two".

2. The intellisense list works only the first time the field activates. If the user tabs to the next field and then tabs back to the first field, the event is triggered again but the member list simply flickers for an instant and then disappears.

3. Finally, I tried to handle the "CodeSnippetFieldModified" event so I could find out what value the user had chosen (or typed in manually), but it seems there's no way to find out what value was actually entered.

Any suggestions? Perhaps I've overlooked something in the documentation?

Thanks!
Jeff

Comments (4)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Jeff,

1) Use the Show method that takes an offset range and make the range the offset range of your "default" value.

2) The caret was being moved right after that event occurred when tabbing after the initial display. I flipped the order of this for the upcoming maintenance release, which fixes the problem.

3) In the documentation's Code Snippets topic, look at the last section. It tells you how you can retrieve the value, and even set a new one.


Actipro Software Support

Posted 17 years ago by Jeff Cohen
Avatar
1) Cool - that works.
2) Great, thanks.
3) Ah! Knew I missed something.

Lastly - any idea how I can auto-advance to the next snippet field after an intellisense choice is made?
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ok I've added the GotoNextField and GotoPreviousField methods to the IntelliPromptCodeSnippets class for you. Those will allow for navigation back and forth through fields. However due to the code snippet handing the Tab key press before the member list can, you run into a sequencing issue. In this scenario you'd probably have to handle KeyTyping and in there in this case, cancel the default key processing, tell the member list to complete and then go to the next field.


Actipro Software Support

Posted 17 years ago by Jeff Cohen
Avatar
Sounds great - thanks so much.

Jeff
The latest build of this product (v24.1.0) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.