none
How to find a "Shift + Tab" on a System.Windows.Input.KeyEventArgs Handler ?

    Question

  • Hello Everybody,

    Well, I´ve been trying to find information for treat "LeftShift + Tab" key press during a System.Windows.Input.KeyEventArgs.

    I´m working with WPF Windows Forms.

    As we know, when you´re using System.Window.Form.KeyEventArgs, to solve the problem you just have to treat the received event into the handler as shown below:

    if(e.KeyCode == Keys.Tab && e.Modifiers == Keys.Alt)
    {
            ...
    }

    But, in WPF the event treated into the TextBox handler is System.Windows.Imput.KeyEventArgs.
    In this case, we don´t have the property "Modifiers".

    Soooo... that´s the problem.

    I would like to thank you in advance.

    Best Regards...

    BrEnO_LEWROY
    [ ]´s Breno

    PS: I´m just needing to change a few textboxes focus.
    • Edited by Breno Lewroy Thursday, July 31, 2008 3:57 PM Including PS.
    Thursday, July 31, 2008 3:18 PM

Answers

  • After start the thread, I found the Modifiers Property.
    But... It doesn´t work. I had to change the handler to:

    private
    void txtPlace_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
    {
        if ((e.KeyboardDevice.IsKeyDown(Key.LeftShift)) && e.KeyboardDevice.IsKeyDown(Key.Tab))
        {
            ...
            e.Handled = true;
        }
    }

    Just before it, I had my problem fixed.

    Thaks By The way...

    = ]


    [ ]´s Breno
    • Marked as answer by Marco Zhou Wednesday, August 06, 2008 9:42 AM
    Friday, August 01, 2008 1:08 PM

All replies

  • In WPF the KeyEventArgs don't have the Modifiers property, it is contained as a public property in the Keyboard class.

    So using:

    if(e.Key == Keys.Tab && Keyboard.Modifiers == Keys.Shift)
    {
            ...
    }

    should work.
    Friday, August 01, 2008 6:31 AM
  • After start the thread, I found the Modifiers Property.
    But... It doesn´t work. I had to change the handler to:

    private
    void txtPlace_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
    {
        if ((e.KeyboardDevice.IsKeyDown(Key.LeftShift)) && e.KeyboardDevice.IsKeyDown(Key.Tab))
        {
            ...
            e.Handled = true;
        }
    }

    Just before it, I had my problem fixed.

    Thaks By The way...

    = ]


    [ ]´s Breno
    • Marked as answer by Marco Zhou Wednesday, August 06, 2008 9:42 AM
    Friday, August 01, 2008 1:08 PM