Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyboard events while dragging

I have two labels on a form. I want to be able to drag one label over the other and while the mouse left button is still down I want to be able to press space key to toggle target label's text between "foo" and "bar".

Seems like all input events are suppressed while mouse left button is not released.

Am I missing something? Any samples?

like image 381
Ramunas Avatar asked Mar 13 '26 13:03

Ramunas


1 Answers

Check out the GiveFeedback event. Maybe you can check from there if a key is being pressed.

EDIT:

void panel1_QueryContinueDrag(object sender, QueryContinueDragEventArgs e)
{
    if (Keyboard.IsKeyDown(Key.Space))
    {
        if (label1.Text == "foo") label1.Text = "bar"; else label1.Text = "foo";
    }
}

and add a reference to PresentaionCore and: WindowBase (You'll find that in: C:\Program Files (x86)\ReferenceAssemblies\Microsoft\Framework\v3.0\ .)

You'll have to play with this a little.

like image 123
ispiro Avatar answered Mar 15 '26 01:03

ispiro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!