Table of Contents

Struct MenuShortcut

Namespace
RDCore.Forms.Menus
Assembly
RDCore.Forms.dll

The key that chooses a menu item from anywhere on its form: a key, by its VB KeyCode, with modifiers.

public readonly record struct MenuShortcut : IEquatable<MenuShortcut>
Implements
Inherited Members

Remarks

Its text is VB's: a modifier prefix (^ for Ctrl, + for Shift, % for Alt) then a letter, a digit, or a key name in braces, as in ^Q, {F2} and +^{DEL}. The key names are the ones VB's SendKeys statement takes: BACKSPACE (or BS or BKSP), BREAK, CAPSLOCK, DELETE (or DEL), DOWN, END, ENTER, ESC, HELP, HOME, INSERT (or INS), LEFT, NUMLOCK, PGDN, PGUP, PRTSC, RIGHT, SCROLLLOCK, TAB, UP, and F1 to F16, in any case.

A VB6 menu's shortcut is one of the keys its Menu Editor lists. Any key of the names above, with any modifiers, is an RD-VBA addition.

Constructors

MenuShortcut(short, ShortcutModifiers)

The key that chooses a menu item from anywhere on its form: a key, by its VB KeyCode, with modifiers.

public MenuShortcut(short KeyCode, ShortcutModifiers Modifiers = ShortcutModifiers.None)

Parameters

KeyCode short

The key's VB KeyCode, such as 81 for Q and 113 for F2.

Modifiers ShortcutModifiers

The modifier keys held with it.

Remarks

Its text is VB's: a modifier prefix (^ for Ctrl, + for Shift, % for Alt) then a letter, a digit, or a key name in braces, as in ^Q, {F2} and +^{DEL}. The key names are the ones VB's SendKeys statement takes: BACKSPACE (or BS or BKSP), BREAK, CAPSLOCK, DELETE (or DEL), DOWN, END, ENTER, ESC, HELP, HOME, INSERT (or INS), LEFT, NUMLOCK, PGDN, PGUP, PRTSC, RIGHT, SCROLLLOCK, TAB, UP, and F1 to F16, in any case.

A VB6 menu's shortcut is one of the keys its Menu Editor lists. Any key of the names above, with any modifiers, is an RD-VBA addition.

Properties

KeyCode

The key's VB KeyCode, such as 81 for Q and 113 for F2.

public short KeyCode { get; init; }

Property Value

short

Modifiers

The modifier keys held with it.

public ShortcutModifiers Modifiers { get; init; }

Property Value

ShortcutModifiers

Methods

ToString()

The shortcut as VB writes it: its modifiers in the order ^, +, %, then its key.

public override string ToString()

Returns

string

The shortcut's text, or an empty string for a key that has no letter, digit or name.

TryParse(string?, out MenuShortcut)

Reads a shortcut written as VB writes it, such as ^Q or {F2}.

public static bool TryParse(string? text, out MenuShortcut shortcut)

Parameters

text string

The shortcut's text.

shortcut MenuShortcut

The shortcut read, or the default where the text is not one.

Returns

bool

Whether the text is a shortcut.