CheckForCodeSnippetShortcut do not work

SyntaxEditor for Windows Forms Forum

Posted 11 years ago by Heribert Scharnagl
Version: 12.1.0304
Platform: .NET 4.5
Environment: Windows 8 (64-bit)
Avatar

Hi

in my class i have a valid loaded CodeSnippetFolder object with one CodeSnippet inside. The shortcut of the CodeSnippet is "swi".

If i use following code and enter "swi" + TAB in the syntaxeditor only the console.writeline works and "swi" appears (the snippet is not inserted).

void syntaxEditor_KeyTyped(object sender, ActiproSoftware.SyntaxEditor.KeyTypedEventArgs e)
{
		if (e.KeyData == Keys.Tab)
		{
			e.Cancel = this.syntaxEditor.IntelliPrompt.CodeSnippets.CheckForCodeSnippetShortcut(_snippetFolder);
			Console.WriteLine(_snippetFolder.CodeSnippets[0].Shortcut);
		}
} 

 The snippet works fine if i use

	this.syntaxEditor.IntelliPrompt.CodeSnippets.ShowInsertSnippetPopup(this.syntaxEditor.Caret.Offset, "Insert snippet:", _snippetFolder, CodeSnippetTypes.Expansion);

 What do i wrong?

[Modified 11 years ago]

Comments (4)

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

Hi Heribert,

CheckForCodeSnippetShortcut will return false if the caret is at the start of the document, another code snippet is already active, or the member list is displayed (not for a code snippet member list).  Also of course if the previous word in front of the caret isn't the shortcut text.

So check all those conditions in your scenario.  Perhaps you have some text before "swi" that its thinking is in the same word?


Actipro Software Support

Posted 11 years ago by Heribert Scharnagl
Avatar

Ooops my fault.

Sry... I used KeyTyped instead of KeyTyping...
So it can't work... 

:)

 

Thx a lot
heribert 

Posted 11 years ago by Heribert Scharnagl
Avatar

Is there any event that will occur if the ShowInsertSnippetPopup is closed

or better

is there any event that will occur if the ShowInsertSnippetPopup is closed and the snippet is inserted...

?

[Modified 11 years ago]

Answer - Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Heribert,

There are a few events related to code snippets.  For more information, please see the "Code Snippets" documentation topic and in there, the "Code Snippet Events" section.


Actipro Software Support

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

Add Comment

Please log in to a validated account to post comments.