共用方式為


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 鍵盤快速鍵) 的 「Select all」 (命令。 我們也將 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 行為。

適用於

另請參閱