Class Shortcut
- Namespace
- UILib
- Assembly
- UILib.dll
A class which represents a shortcut. This holds important information about a shortcut such as the event listener and underlying keybinds.
Also has a useful field canRun which indicates whether a shortcut can run. This takes into consideration a variety of cases including:
- UILib's
InputOverlaywaiting for an input - An input field being selected (to avoid triggering while typing/deselecting)
- The player is editing keybinds in the
InGameMenu
public class Shortcut
- Inheritance
-
Shortcut
- Inherited Members
Constructors
Shortcut(IList<ConfigEntry<KeyCode>>)
Initializes a shortcut using the provided KeyCodes
wrapped in BepInEx ConfigEntry types.
All keys must be down for the shortcut to trigger.
As the provided ConfigEntry types are references, any updates
to their Value are automatically/naturally picked up by this shortcut.
There is no reason to call SetShortcut(IList<KeyCode>, IList<ConfigEntry<KeyCode>>) again in this case.
public Shortcut(IList<ConfigEntry<KeyCode>> keys)
Parameters
keysIList<ConfigEntry<KeyCode>>The keys for the shortcut
Shortcut(IList<KeyCode>)
Initializes a shortcut using the provided KeyCodes.
All keys must be down for the shortcut to trigger.
public Shortcut(IList<KeyCode> keys)
Parameters
keysIList<KeyCode>The keys for the shortcut
Shortcut(IList<KeyCode>, IList<ConfigEntry<KeyCode>>)
Initializes a shortcut.
Both arguments are optional.
All provided keys and bepInKeys must be down
for the shortcut to trigger.
As the provided ConfigEntry types are references, any updates
to their Value are automatically/naturally picked up by this shortcut.
There is no reason to call SetShortcut(IList<KeyCode>, IList<ConfigEntry<KeyCode>>) again in this case.
public Shortcut(IList<KeyCode> keys = null, IList<ConfigEntry<KeyCode>> bepInKeys = null)
Parameters
keysIList<KeyCode>The shortcut's plain keys
bepInKeysIList<ConfigEntry<KeyCode>>The shortcut's BepInEx
ConfigEntrykeys
Properties
bepInKeys
Like keys but holds the BepInEx
ConfigEntry keys.
public Dictionary<ConfigEntry<KeyCode>, bool> bepInKeys { get; }
Property Value
- Dictionary<ConfigEntry<KeyCode>, bool>
canRun
A static property which indicates whether a shortcut can run.
Shortcuts can't run in these cases:
- UILib's
InputOverlaywaiting for an input - An input field being selected (to avoid triggering while typing/deselecting)
- The player is editing keybinds in the
InGameMenu
public static bool canRun { get; }
Property Value
enabled
Whether this shortcut is currently enabled.
public bool enabled { get; }
Property Value
keys
Which KeyCodes need to be entered
at the same time for this shortcut
to trigger.
public Dictionary<KeyCode, bool> keys { get; }
Property Value
- Dictionary<KeyCode, bool>
onHold
The event which triggers for the entire duration the shortcut is held.
public UnityEvent onHold { get; }
Property Value
- UnityEvent
onTrigger
The event which is triggered when this shortcut is entered.
public UnityEvent onTrigger { get; }
Property Value
- UnityEvent
Methods
Disable()
Disables this shortcut. This prevents it from being triggered.
public void Disable()
Enable()
Enables this shortcut. This allows it to be triggered.
By default shortcuts are enabled anyway, so you'd only need to use this if you have already disabled it.
public void Enable()
SetShortcut(IList<KeyCode>, IList<ConfigEntry<KeyCode>>)
Sets a different shortcut to use instead.
Both arguments are optional.
All provided keys and bepInKeys must be down
for the shortcut to trigger.
public void SetShortcut(IList<KeyCode> keys = null, IList<ConfigEntry<KeyCode>> bepInKeys = null)