|
struct KeyInfo
The structure represents the underlying data associated with a single entry in .key files. It contains two fields: a name and an array of four elements used to store information about physical key combinations. The structure can hold up to four such combinations. However, only two are currently utilized.
The following example shows how the structure is used, assuming the presence of the following entries in the MyApp.key file:
KEY(SAVE_FILE, "Save", K_CTRL_S)
KEY2(CUT_LINE, "Cut line", K_CTRL_Y, K_CTRL_L)
In this case, the file should be imported as follows in the .cpp file:
#define KEYGROUPNAME "MyApp"
#define KEYNAMESPACE MyAppKeys
#define KEYFILE <MyApp/MyApp.key>
#include <CtrlLib/key_source.h>
The structure can now be used in various contexts, such as when creating a menu bar entry, as shown below:
menu.AddMenu(MyAppKeys::AK_SAVE_FILE, [=] { Save(); });
Typically, at the beginning of your file, you can use using namespace MyAppKeys to simplify the line above to:
using namespace MyAppsKeys;
...
menu.AddMenu(AK_SAVE_FILE, [=] { Save(); });
In this case, AK_SAVE is a KeyInfo structure.
Please note that KEY is used when only one key combination should be associated with a given operation, whereas KEY2 is used when two separate combinations can activate the operation.
const char *name
The name of the operation (for example, “Print”, “Open”, etc.).
dword key[4]
The structure can accommodate up to four physical key shortcuts per operation, though only two are currently utilized. The remaining capacity is reserved for future use.
|