SolidKit.CommandTrigger class

From Solid Graphics Wiki

Jump to: navigation, search
SolidKit.CommandTrigger class
Namespace: SolidKit
Base type: (None)
Assembly: SolidKit.dll
Platform: .NET

The CommandTrigger class allows keyboard/mouse shortcuts customization. It triggers command start/end events based on keyboard or mouse input.

The class implementation allows to assign multiple shortcut keys to a command, or one shortcut key to multiple commands. Typical class use is to load commands definitions using the LoadCommandInfoFromString method, then loading key-shortcuts assignment using the LoadKeysFromString, subscribing for command start/end notifications using Subscribe methods. Application then should call OnKeyDown, OnKeyUp methods in response to keyboard/mouse presses/depresses events in the application window. Once a configured shortcut key is pressed then the CommandTrigger object calls callback method (which was previously provided by the call to the Subscribe method) which then can process the triggered command.


Default constructor initializes the instance to disabled state with no event subscribers and no command or key-shortcuts defined. The copy constructor initializes the instance with another class instance settings.


The CommandTrigger class has no public fields.


Method name Description
Subscribe Subscribes given callback for receiving command start/end events.
UnSubscribe Unsubscribes given callback from receiving command start/end events.
Enable Enables firing of command start/end events.
Disable Disables firing of command start/end events.
IsEnabled Returns true if firing of events is enabled, otherwise returns false.
OnCommand Overridable virtual function which is called when command start/end event is fired.
OnKeyDown By calling the OnKeyDown function the application informs the CommandTrigger instance that a key (keyboard or mouse button) was pressed. Typically an application calls this function when WM_KEYDOWN message was received by active window.
OnKeyUp By calling the OnKeyDown function the application informs the CommandTrigger instance that a key (keyboard or mouse button) was depressed. Typically an application calls this function when WM_KEYUP message was received by active window.
OnGetFocus By calling the OnGetFocus function the application informs the CommandTrigger instance that the window which messages is "processing" got focus.
OnKillFocus By calling the OnKillFocus function the application informs the CommandTrigger instance that the window which messages is "processing" lost focus.
LoadCommandInfoFromString Loads information about commands fired by the CommandTrigger instance. The information include command id numbers and category number for each command.
LoadKeysFromString Loads key-shortcuts information for defined commands from a string.
SaveCommandInfoToString Saves commands information to a string.
SaveKeysToString Saves command key-shortcuts information to a string.
GetSettingsDisplayString Returns current commands and key-shortcuts information into human-readable string.

Following methods are advanced. Instead of using methods below an application can use SolidKit.Forms.Dialogs.CustomizeShortcutKeysDialog class which provides dialog based interface for setting command key-shortcuts.

Method name Description
AddCommandKey Adds a command key-shortcut.
EraseCommandKey Erases specified command key-shortcut.
EraseCommandKeys Erases all key-shortcuts defined for the command.
EraseAllCommandsKeys Erases all key-shortcuts for all commands.
EraseAllCommands Erases all commands and their shortcuts.
GetCommandsCount Gets number of currently defined commands.
GetCommandInfoByCommandIndex Retrieves information such as command id, command category and command description for a command specified by it's index. Number of valid command indexes ranges from zero to number returned by the GetCommandsCount method minus one.
GetCommandId Returns command id from command index.
GetCommandInfo Returns command information from given command id.
GetCommandCategoriesCount Retrieves current number of defined command categories.
GetCommandCategoryInfo Retrieves category information from given category index.
GetCategoryCommandIds Retrieves list of command ids for given category id.
GetCommandKeysCount Retrieves number of key-shortcuts defined for given category id.
GetCommandKey Retrieves key-shortcut information for specified command id and key-shortcut index.
GetCommandKeyCommandIds Retrieves all command ids for all commands defined for the key-shortcuts.
IsCommandKeyDefined Returns true is given key-shortcut is defined for given command, otherwise returns false.

See Also


SolidKit Library Documentation

Personal tools