MenuSys

IsShortCut

Run the menu action assigned to a shortcut key

Syntax

Signature
xBool IsShortCut( TopBarMenu *topBar, int key, int *id );

Arguments

topBar the root menu to search. NULL returns F.

key the key code to match against the shortcut stored on an item. 0 returns F.

id receives the item's identifier on success, or use NULL to discard the identifier.

Return value

T on success, or F if the top bar is NULL, the key is 0 or the search finds no eligible match. The output identifier is written only on success.

Description

Include xdev-wtui-classes.h. Search the top bar for the first item with the given key. If that item is disabled or owns a submenu, the function returns `F`. If the bar has no match for the key, search the submenus of enabled items, starting at the bar's current item or at the first one when the current position is `0`, then wrapping around the bar.

In each pop-up, check its direct items first. If there is no direct match, search the submenus of its enabled items in order. A disabled direct match or a match that opens another submenu ends the search of that branch.

For an eligible match, the function selects the item in its own menu and calls its callback if present. It then writes the item's identifier through `id` if supplied. Shortcut dispatch can run a callback while its submenu is closed. It succeeds even when the item's identifier is `0`.

See also