AutoReplaceTrigger on keypress

SyntaxEditor for Windows Forms Forum

Posted 12 years ago by BLANC Stéphane - Staubli Robotics Suite Product Manager, STAUBLI
Version: 4.0.0262
Avatar
Hello

Is it possible to activate the autoreplace function each time the user press a new key ?

I want to replace the user input just after the last character of the word without having to press the Enter key.

For example :
endif will be replaced by endIf just after entering the 'f'

Thanks for your help

Regards

Stéphane

Comments (3)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You could add more triggers or call EditorView.PerformAutoReplace on the SelectedView in any KeyTyped event where an appropriate key is typed. Hope that helps!


Actipro Software Support

Posted 12 years ago by BLANC Stéphane - Staubli Robotics Suite Product Manager, STAUBLI
Avatar
it's not working for me...

* Solution 1 : I defined the following trigger activator

<AutoReplaceTriggerActivator Character="f" />
but it doesn't work

* Solution 2 : I added the following code in the keypressed event

for (int l_i = 0; l_i< m_editor.Views.Count; l_i++)
{
    m_editor.Views[l_i].PerformAutoReplace();
}
but it doesn't work

Any idea ?
Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
I see the problem, when you have a trigger, it looks at the token before the inserted character. But in this case 'f' is part of the current token so it's looking at the wrong token.

But this other way works. Instead of KeyPress, put this in the KeyTyped event:
if (e.KeyChar == 'f')
  this.SelectedView.PerformAutoReplace();


Actipro Software Support

The latest build of this product (v2020.1 build 0400) was released 8 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.