KeyboardAccelerator.Invoked 事件

定义

按下此 KeyboardAccelerator 的组合键时发生。

// Register
event_token Invoked(TypedEventHandler<KeyboardAccelerator, KeyboardAcceleratorInvokedEventArgs const&> const& handler) const;

// Revoke with event_token
void Invoked(event_token const* cookie) const;

// Revoke with event_revoker
KeyboardAccelerator::Invoked_revoker Invoked(auto_revoke_t, TypedEventHandler<KeyboardAccelerator, KeyboardAcceleratorInvokedEventArgs const&> const& handler) const;
public event TypedEventHandler<KeyboardAccelerator,KeyboardAcceleratorInvokedEventArgs> Invoked;
function onInvoked(eventArgs) { /* Your code */ }
keyboardAccelerator.addEventListener("invoked", onInvoked);
keyboardAccelerator.removeEventListener("invoked", onInvoked);
- or -
keyboardAccelerator.oninvoked = onInvoked;
Public Custom Event Invoked As TypedEventHandler(Of KeyboardAccelerator, KeyboardAcceleratorInvokedEventArgs) 

事件类型

示例

此示例显示了如何在自定义 ListView 控件中覆盖“全选”命令(Ctrl+A 键盘加速键)。 我们还将 Handled 属性设置为 true 以停止以后的事件浮升。

public class MyListView : ListView
{
  …
  protected override void OnKeyboardAcceleratorInvoked(KeyboardAcceleratorInvokedEventArgs args) 
  {
    if(args.KeyboardAccelerator.Key == VirtualKey.A 
      && args.KeyboardAccelerator.Modifiers == VirtualKeyModifiers.Control)
    {
      CustomSelectAll(TypeOfSelection.OnlyNumbers); 
      args.Handled = true;
    }
  }
  …
}

注解

处理此事件以替代默认的 KeyboardAccelerator 行为。

适用于

另请参阅