共用方式為


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 行為。

適用於

另請參閱