The IAccelerator class represents a set of accelerator keys, which are shortcut keys for running an action. Often these actions match the actions available from a menu.
A set of accelerator keys is also known as an accelerator table. Use the IAccelerator class to associate an accelerator table defined in a resource library with a window. The accelerator keys are in effect only when the window associated with the accelerator table has the keyboard focus.
The IAcceleratorTable class also represents an accelerator table. See that class for additional information on accelerator tables.
You can construct and destruct objects of this class. You cannot copy or assign IAccelerator objects because both the copy constructor and assignment operator are private functions.
The constructors accept a window that uses the accelerator keys.
The accelerators are only in effect when the specified
IWindow object has the input focus.
Note:
IAccelerator* pac1 = new IAccelerator(myAccelRes);
IAccelTblHandle haccel1 = pac1->accel();
delete pac1;
pac1 = new IAccelerator(haccel1);
// The accelerator handle (haccel1)
// is no longer valid.
![]() |
public:
~IAccelerator()
The object and the underlying accelerator table are destroyed. If a window was associated with the accelerator and that window is still valid, its original accelerator table is restored. If, after restoring the original accelerator table, there is a saved accelerator table that is not in use, that table is also destroyed.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
IAccelerator( const IResourceId& accelResId, IWindow* owner = 0 )
Loads an accelerator table from a resource library and assigns it to a window. Use this constructor when you want to load the accelerator table from the resource library of your choice.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
IAccelerator(unsigned long accelResId, IWindow* owner = 0)
Loads an accelerator table from the default user resource library and assigns it to a window. Use this constructor if you want to load the accelerator table from the resource library returned by ICurrentApplication::userResourceLibrary.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
IAccelerator( const IAccelTblHandle& haccel = 0, IWindow* owner = 0 )
Assigns an existing accelerator table to a window. Use this constructor when the accelerator table is already loaded.
Windows | OS/2 | AIX |
Yes | Yes | No |
Accelerator tables contain a list of shortcut key definitions. You can set, remove, and query the accelerator table currently in use by the object.
![]() |
public:
IAccelTblHandle handle() const
Returns a handle to the accelerator table.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
bool isSet() const
If the accelerator table is assigned to a window, true is returned (calling owner returns the window). This function returns false if you have removed the accelerator table by calling remove or reset.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
IAccelerator& remove()
Removes the accelerator table without restoring the one that was previously in effect. Calling this function destroys the underlying accelerator table. If you then try to use the IAccelTblHandle after removing it, an exception is thrown.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
IAccelerator& reset()
Removes the accelerator table and restores the one that was in effect before the previous call to set.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
Changes the accelerator keys represented by this object
and used by the owner window of this accelerator table.
The accelerator table previously used by the IAccelerator object is saved,
and can be restored by calling
reset.
Note:
public:
IAccelerator& set(const IAccelTblHandle& haccel)
Use this function when the accelerator table is already loaded.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
IAccelerator& set(const IResourceId& accelResId)
Use this function when you want to specify the resource library that the Open Class Library uses to load the accelerator table.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
IAccelerator& set(unsigned long accelResId)
Use this function when you want the Open Class Library to load the accelerator table from the default user resource library (the resource library returned by ICurrentApplication::userResourceLibrary).
Windows | OS/2 | AIX |
Yes | Yes | Yes |
You can apply accelerator keys to any window. Only when a window with accelerators has the input focus (or one of its child windows has the input focus) will your pressing an accelerator key cause the command associated with the accelerator key to be run.
![]() |
public:
IWindow* owner() const
Returns the IWindow using the accelerator table.
Windows | OS/2 | AIX |
Yes | Yes | Yes |