-
Notifications
You must be signed in to change notification settings - Fork 3
KeyboardShortcuts.KeyRegistry
Back to home | Back to Reference | View raw text
A class to hold and handle keyboard shortcuts, and determine which shortcut to use based upon key presses.
flowchart LR
classDef interfaceStyle stroke-dasharray: 5 5;
classDef abstractStyle stroke-width:4px
subgraph SolidShineUi.KeyboardShortcuts
SolidShineUi.KeyboardShortcuts.KeyRegistry[[KeyRegistry]]
end
Type | Name | Methods |
---|---|---|
IReadOnlyList <KeyboardShortcut > |
RegisteredShortcuts A read-only list of all keyboard shortcuts registed in this registry. Use the RegisteryKeyShortcut and UnregisterKeyShortcut methods to add or remove shortcuts. |
get |
Returns | Name |
---|---|
(IKeyAction Item1, string Item2) |
GetActionForKey (... )Get the IKeyAction associated with a certain keyboard shortcut. |
IEnumerable <KeyboardShortcut > |
GetShortcutsForMethod (string methodId)Get a list of keyboard shortcuts registered to a certain method. |
void |
RegisterKeyShortcut (... )Register a keyboard shortcut with the registry. |
bool |
UnregisterKeyShortcut (... )Unregister (remove) a shortcut from this registry. |
A class to hold and handle keyboard shortcuts, and determine which shortcut to use based upon key presses.
public KeyRegistry()
public void RegisterKeyShortcut(KeyboardShortcut kc)
Type | Name | Description |
---|---|---|
KeyboardShortcut |
kc | The keyboard shortcut to register. |
Register a keyboard shortcut with the registry.
public void RegisterKeyShortcut(KeyboardCombination combination, Key key, IKeyAction action)
Type | Name | Description |
---|---|---|
KeyboardCombination |
combination | The combination of modifier keys to press for this shortcut. |
Key |
key | The specific key that activates this keyboard shortcut. |
IKeyAction |
action | The action to perform when the keyboard shortcut is pressed. |
Register a keyboard shortcut with the registry.
public bool UnregisterKeyShortcut(KeyboardShortcut ks)
Type | Name | Description |
---|---|---|
KeyboardShortcut |
ks | The keyboard shortcut to unregister. |
Unregister (remove) a shortcut from this registry.
This overload of this method looks for a specific keyboard shortcut instance that is currently in the registry. To remove based upon the keys being pressed, use the other overload instead ( KeyRegistry.UnregisterKeyShortcut(SolidShineUi.KeyboardShortcuts.KeyboardCombination,System.Windows.Input.Key) ).
Returns if the shortcut was able to be removed or not. Will return false if this registry does not contain this specific shortcut.
public bool UnregisterKeyShortcut(KeyboardCombination combination, Key key)
Type | Name | Description |
---|---|---|
KeyboardCombination |
combination | The combination of modifier keys to be pressed for this shortcut. |
Key |
key | The key to press to activate this shortcut. |
Unregister (remove) a shortcut from this registry.
True if the shortcut was found and removed; false if there is no shortcut with this particular key and modifier key combination.
public IEnumerable<KeyboardShortcut> GetShortcutsForMethod(string methodId)
Type | Name | Description |
---|---|---|
string |
methodId | The name of the method. If you used RoutedEventKeyAction.CreateListFromMenu(SolidShineUi.Menu) to fill from a menu, the name will be the name of the MenuItem itself. |
Get a list of keyboard shortcuts registered to a certain method.
public (IKeyAction Item1, string Item2) GetActionForKey(KeyboardCombination combination, Key key)
Type | Name | Description |
---|---|---|
KeyboardCombination |
combination | The combination of modifier keys to have pressed for this shortcut. |
Key |
key | The key for this shortcut. |
Get the IKeyAction associated with a certain keyboard shortcut.
A Tuple containing the IKeyAction associated with this shortcut, if there is one (null if there is not), and a friendly string that displays the keyboard combination to press (i.e. "Ctrl+Alt+V").
public (IKeyAction Item1, string Item2) GetActionForKey(Key key, bool shift, bool alt, bool ctrl)
Type | Name | Description |
---|---|---|
Key |
key | The key for this shortcut. |
bool |
shift | Set if the Shift key is part of this shortcut. |
bool |
alt | Set if the Alt key is part of this shortcut. |
bool |
ctrl | Set if the Ctrl key is part of this shortcut. |
Get the IKeyAction associated with a certain keyboard shortcut.
A Tuple containing the IKeyAction associated with this shortcut, if there is one (null if there is not), and a friendly string that displays the keyboard combination to press (i.e. "Ctrl+Alt+V").
public IReadOnlyList<KeyboardShortcut> RegisteredShortcuts { get; }
A read-only list of all keyboard shortcuts registed in this registry. Use the RegisteryKeyShortcut and UnregisterKeyShortcut methods to add or remove shortcuts.
public event KeyboardShortcutEventHandler ShortcutRegistered
Raised when a shortcut is added (registered) to this KeyRegistry.
public event KeyboardShortcutEventHandler ShortcutUnregistered
Raised when a shortcut is removed (unregistered) from this KeyRegistry.
public delegate void KeyboardShortcutEventHandler(object sender, KeyboardShortcutEventArgs e)
Type | Name | Description |
---|---|---|
object |
sender | |
KeyboardShortcutEventArgs |
e |
Generated with ModularDoc