The following seems to work
public class Script
{
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
Stopwatch stopwatch = new Stopwatch();
long ts=0; // var to hold the time between the last change of text and when the next control got focus
EpiNumericEditor nextCtrl; // this is the next control in the tab order your type my vary
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.txtTest1.TextChanged += new System.EventHandler(this.txtTest1_TextChanged);
this.txtTest1.AfterEnterEditMode += new System.EventHandler(this.txtTest1_AfterEnterEditMode);
// End Wizard Added Custom Method Calls
// get the reference to the next control in the tab order. Use the GUID of the next control after your text box
nextCtrl = (EpiNumericEditor)csm.GetNativeControlReference("1e69f533-0300-4552-8f91-6051dc75e88d");
this.nextCtrl.GotFocus += new System.EventHandler(this.nextCtrl_GotFocus);
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.txtTest1.TextChanged -= new System.EventHandler(this.txtTest1_TextChanged);
this.txtTest1.AfterEnterEditMode -= new System.EventHandler(this.txtTest1_AfterEnterEditMode);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
this.nextCtrl.GotFocus -= new System.EventHandler(this.nextCtrl_GotFocus);
// End Custom Code Disposal
}
private void nextCtrl_GotFocus(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
stopwatch.Stop();
long ts = stopwatch.ElapsedMilliseconds;
if(ts < 200){ // Might have to play with this value
// Add the newline to the end. Might want to test if last char is already a newline.
txtTest1.Text = txtTest1.Text + Environment.NewLine;
txtTest1.Focus();
}
}
private void txtTest1_TextChanged(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
//Restart stopwatch after every change to text value.
stopwatch.Restart();
}
private void txtTest1_AfterEnterEditMode(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
txtTest1.SelectionStart = txtTest1.Text.Length;
txtTest1.SelectionLength = 0;
}