amit kohan
amit kohan

Reputation: 1618

Esc handler ignored

Following code, doesn't get triggered when Esc is pressed. Can somebody give me insight? I like to change the cursor (let's say from drawing mode turn it into pointer mode)

    public override void OnKeyDown(MyCanvas dc, KeyEventArgs e)
    {
        if (e.Key == Key.Escape)
        {
            _line = null;
            e.Handled = true;
        }
    }

Thanks.

Upvotes: 0

Views: 59

Answers (1)

Kirk Broadhurst
Kirk Broadhurst

Reputation: 28718

@amit's solution:

public override void OnKeyDown(MyCanvas dc, KeyEventArgs e)
{
    if (e.Key == Key.Escape)
    {
        _line = null;
        dc.CurrentTool = ToolType.Pointer;
        dc.Cursor = Cursors.Arrow;
        dc.ReleaseMouseCapture();

    }
}

Upvotes: 2

Related Questions