ArcObjects Library Reference (Framework)  

IAccelerator Interface

Provides access to members that define an accelerator.

Product Availability

Available with ArcGIS Desktop.

Description

An accelerator is a mapping between a particular keyboard combination and a command. When you press the combination of keys on the keyboard, the command is executed. For example, Ctrl-C is a well-known accelerator for copying something in Windows. Some commands in the application already have accelerators assigned to them but you can also assign additional accelerators to these commands.

Use the IAcceleratorTable::Add method to create an accelerator.

Members

Description
Read/write property Alt Indicates if the Alt key is pressed for this accelerator.
Read/write property CommandID The identifier of the command that this accelerator activates.
Read/write property Ctrl Indicates if the Ctrl key is pressed for this accelerator.
Method Delete Removes this accelerator from the accelerator table.
Read/write property Key The keycode for this accelerator.
Read/write property Shift Indicates if the Shift key is pressed for this accelerator.

CoClasses that implement IAccelerator

CoClasses and Classes Description
Accelerator Accelerator object.

Remarks

The following example prints the keyboard accelerator assigned to the built-in Copy command. You would get m_app from the hook in ICommand::OnCreate().

[C#]
IAcceleratorTable pAccTable = m_app.Document.Accelerators;
UID uid = new UIDClass();
uid.Value = "{A33D9405-7ED5-11D0-8D7C-0080C7A4557D}";//Edit_Copy command
IArray pAccArr = pAccTable.Find(uid);
for (int i = 0; i < pAccArr.Count; i++)
{
  IAccelerator pAcc = pAccArr.get_Element(i)as IAccelerator;
  System.Windows.Forms.MessageBox.Show("Ctrl == " + pAcc.Ctrl.ToString() + "\n" + "Alt == " + pAcc.Alt.ToString()
    + "\n" + "Shift == " + pAcc.Shift.ToString() + "\n" + "Key == " + Convert.ToChar(pAcc.Key));
}
[Visual Basic .NET]
Dim pAccTable As IAcceleratorTable = m_app.Document.Accelerators
Dim uid As UID = New UIDClass()
uid.Value = "{A33D9405-7ED5-11D0-8D7C-0080C7A4557D}"
'Edit_Copy command
Dim pAccArr As IArray = pAccTable.Find(uid)
Dim i As Integer = 0
While i < pAccArr.Count
 Dim pAcc As IAccelerator = TryCast(pAccArr.get_Element(i), IAccelerator)
 System.Windows.Forms.MessageBox.Show("Ctrl == " + pAcc.Ctrl.ToString() + vbLf + "Alt == " + pAcc.Alt.ToString() + vbLf + "Shift == " + pAcc.Shift.ToString() + vbLf + "Key == " + Convert.ToChar(pAcc.Key))
 System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While

See Also

IAcceleratorTable.FindByKey Method | IAcceleratorTable.Add Method | IAcceleratorTable.Item Property