【发布时间】:2013-08-16 08:06:22
【问题描述】:
无法在 Alt+Key 上获取事件。示例 Alt+E。 E 和 Alt 的事件触发,但没有 Alt+E
IKeyProcessorProvider 中的 Mb 问题?我有用户控件,想要使用内部控件ButtonKeyProc.KeyDownEvent+=。
[Export(typeof(IKeyProcessorProvider))]
[TextViewRole(PredefinedTextViewRoles.Document)]
[ContentType("any")]
[Name("ButtonProvider")]
[Order(Before = "default")]
internal class ButtonProvider : IKeyProcessorProvider
{
[ImportingConstructor]
public ButtonProvider()
{
}
public KeyProcessor GetAssociatedProcessor(IWpfTextView wpfTextView)
{
return new ButtonKeyProc(wpfTextView);
}
}
internal class ButtonKeyProc : KeyProcessor
{
internal static event KeyEventHandler KeyDownEvent;
public ButtonKeyProc(ITextView textView)
{
}
public override void KeyDown(KeyEventArgs args)
{
if (args.Key == Key.E && IsAlt)
{
if (KeyDownEvent != null)
{
KeyDownEvent(this, args);
}
}
}
public bool IsAlt
{
get { return Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt); }
}
【问题讨论】:
-
为什么不检查
args.Alt?
标签: c# visual-studio visual-studio-extensions