C# 忽略Esc处理程序
按下Esc时不会触发以下代码。有人能给我一些见解吗? 我喜欢更改光标(比如从绘图模式转换为指针模式) 谢谢。@amit的解决方案:C# 忽略Esc处理程序,c#,wpf,C#,Wpf,按下Esc时不会触发以下代码。有人能给我一些见解吗? 我喜欢更改光标(比如从绘图模式转换为指针模式) 谢谢。@amit的解决方案: public override void OnKeyDown(MyCanvas dc, KeyEventArgs e) { if (e.Key == Key.Escape) { _line = null; dc.CurrentTool = ToolType.Pointer; dc.Cursor = Cu
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();
}
}
您是否在函数中设置了断点,并在按下任意键时验证是否调用了该断点?谢谢…通过在top(编辑:)@amitkohan中添加代码解决了此问题,而不是更改您的问题,请将您的解决方案放在下面的“答案”部分,并将其标记为已回答。hmmm。我在修改时没有注意到这样的链接/按钮。
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();
}
}