Alt无法在+上获得事件Key。示例Alt+ E。E为and触发事件Alt,但在 ? 中没有Alt+ E
Mb 问题IKeyProcessorProvider
?我有用户控件,并且想要使用内部控件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); }
}