0

I am New to Windows mobile application. I am developing an windows mobile application for touch device (devices with Hardware key). I want to programmatically figure out difference between user tap on ComboBox (by finger/stylus) or presses arrow Key (using arrow key for list traversing). Because at both time it calls selectedIndexChanged. Is there any event for ComboBox TAP or swipe ?

Any help is appreciated.

Thanks
Manish Kumar

1 Answers1

1

There is no such event.

My suggestion is to flag for finger/stylus clicks in the form event Click and to flag for arrow key presses in the for event KeyDown. That way you can seperate between the two in the SelectedIndexChange event. Something like:

enum InteractionType
{
    Click,
    KeyDown
}

private InteractionType _userInteractionType;


private void form_Click(object sender, EventArgs e)
{
    _userInteractionType = InteractionType.Click;
}

private void form_KeyDown(object sender, KeyEventArgs e)
{
    e.Handled = true;
    switch (e.KeyCode)
    {
        case Keys.Up:
        case Keys.Down:
            _userInteractionType = InteractionType.KeyDown;
            break;
    }
}

private void comboBox_SelectedIndexChanged(object sender, EventArgs e)
{
    switch (_userInteractionType)
    {
        case InteractonType.Click:
            // do something
            break;
        case InteractionType.KeyDown;
            // do something else
            break;
    }
}

If you need to do this often and in many places it's probably worth creating a form base class for your project and do something simular by overriding OnClick and OnKeyDown.

Fredrik Ljung
  • 1,445
  • 13
  • 28