Catch key pressed on SIP

  • Thread starter Thread starter Andreas Schulz
  • Start date Start date
A

Andreas Schulz

Hi,

in my PPC application I want to catch the event when the "return" key is
pressed on the SIP. Does anyone know how to do this?

Thanks

Andreas
 
Andreas,

First I am assuming you have a form with at least one or more TextBox's and
with the SIP raised. Catching the ENTER key is something I do to move the
cursor to the next TextBox. To do this, use the KeyPress event associated
with each TextBox and map it to an event handler. Here is an example of my
handler code:

public static void NextOnEnter(object obj, KeyPressEventArgs e)
{
// Trap ENTER key and change focus to next TextBox control
if (e.KeyChar == 13)
{
int i;
int ii = 0;
TextBox txb = (TextBox) obj; // Get the TextBox control from
object
Control control = txb.Parent; // Get the Parent control
i = control.Controls.IndexOf(txb); // Get the position of this
TextBox control in the collection
while (ii == 0)
{
// Increment the control number
i++;
// Check if last control reached. If so, set back to first one.
if (i == control.Controls.Count)
{
i = 0;
}
// Check if this control is a TextBox type. If not, keep
incrementing.
if (control.Controls.GetType().Name == "TextBox")
{
ii = 1;
}
}
// Set focus to the next TextBox control in sequence
control.Controls.Focus()
}
}

Regards,
Neville Lang
 
Thanks Neville. I was actually just looking for the event to fire and
did already myself. You are right I have a single textbox and when the
enter key is pressed I want to hide the sip and leave the dialog. I made
it and thank you once again for your help.

Andreas

Neville said:
Andreas,

First I am assuming you have a form with at least one or more TextBox's and
with the SIP raised. Catching the ENTER key is something I do to move the
cursor to the next TextBox. To do this, use the KeyPress event associated
with each TextBox and map it to an event handler. Here is an example of my
handler code:

public static void NextOnEnter(object obj, KeyPressEventArgs e)
{
// Trap ENTER key and change focus to next TextBox control
if (e.KeyChar == 13)
{
int i;
int ii = 0;
TextBox txb = (TextBox) obj; // Get the TextBox control from
object
Control control = txb.Parent; // Get the Parent control
i = control.Controls.IndexOf(txb); // Get the position of this
TextBox control in the collection
while (ii == 0)
{
// Increment the control number
i++;
// Check if last control reached. If so, set back to first one.
if (i == control.Controls.Count)
{
i = 0;
}
// Check if this control is a TextBox type. If not, keep
incrementing.
if (control.Controls.GetType().Name == "TextBox")
{
ii = 1;
}
}
// Set focus to the next TextBox control in sequence
control.Controls.Focus()
}
}

Regards,
Neville Lang



Hi,

in my PPC application I want to catch the event when the "return" key is
pressed on the SIP. Does anyone know how to do this?

Thanks

Andreas
 
Back
Top