<@interface name="KitHotkeys" alias="$ENV"> Extension point for defining kit hot keys (c) SAP AG 2003-2006. All rights reserved. + # The hotkey scope # The hotkey code # See "@KitCommands!defineCommand" Example GmlDrawing 113 function defineHotkey(scope, code, cmd) { if (!scope || !code) return null; var def = (typeof cmd == 'string' ? getCommand(cmd) : cmd); if (!def || (typeof def != 'object')) return raiseKitError('Invalid hotkey "'+code+'" definition'); scope = UPPER(scope); if (!(scope in _kitHotkeys)) _kitHotkeys[scope] = {}; _kitHotkeys[scope][code+''] = def; return def; } <@method name="getHotkey"> Returns the command associated with a specified hotkey The hotkey scope The hotkey code The command associated with the requested hotkey function getHotkey(scope, code) { var K=_kitHotkeys[UPPER(scope)]; return K && K[code+''] || null; } <@method name="getHotkeysTable"> Returns the complete hotkeys table Table of command objects, indexed by hotkey scope and code Hotkey scope id's are stored in uppercase. Use @lib:Basic!UPPER macro to convert the Hotkey scope id to uppercase before using it as the index in this table. function getHotkeysTable() { return _kitHotkeys; } <@method name="getHotkeysByScope"> Returns the table of hotkeys in a specified scope The hotkeys table scope Table of command objects, indexed by hotkey code function getHotkeysByScope(scope) { var K=_kitHotkeys[UPPER(scope)]; return K || null; } <@method name="removeHotkey"> Removes a specified hotkey definition The hotkey scope The code of the hotkey to remove function removeHotkey(scope, code) { var K=_kitHotkeys[UPPER(scope)]; if (K) delete K[code+'']; } <@method name="parseHotkey" scope="private"> Parses the given hotkey node and returns a string which represents its details Hotkey node to parse function parseHotkey(hotkeyNode) { var map = getNodeProps(hotkeyNode); var res=""; if (!map) return res; var scope = map['scope']; var code = map['code']; var cmdNode = hotkeyNode && hotkeyNode.selectSingleNode('COMMAND'); if (!scope || !code || !cmdNode) return res; var cmdMap = getNodeProps(cmdNode); if (!cmdMap) return res; var size=0; for (var k in cmdMap) size++; // get the map's size var id = cmdMap['id']; if (id && size==1) // only 'id' was provided res+="$ENV.defineHotkey(" + STR(scope) + "," + STR(code) + "," + STR(id) + ");"; else res+="$ENV.defineHotkey(" + STR(scope) + "," + STR(code) + "," + __xmlMap2Str(cmdMap) + ");"; return res; }