GM.registerMenuCommand

From GreaseSpot Wiki
Revision as of 16:34, 26 March 2011 by Arantius (talk | contribs) (→‎Arguments: documentation, mostly as links to the underlying Mozilla attributes)
Jump to navigationJump to search


Description

This method allows user scripts to add an item to the User Script Commands menu.

Compatibility: Greasemonkey 0.2.5+

Syntax

function GM_registerMenuCommand( caption, commandFunc, accelKey, accelModifiers, accessKey )

Arguments

caption
String The caption to display on the menu item.
commandFunc
Function The function to call when this menu item is selected by the user.
accelKey
String or <codeNumber A single character or keycode that can trigger the command. (See accelerator notes section.)
accelModifiers
String A string listing modifiers that may/must be pressed with the accelKey. (See accelerator notes section.)
accessKey
String A single character that can be used to select command when the menu is open. It should be a letter in the caption. [1]

Accelerator Notes

The accelKey and accelModifiers are used verbatim for a XUL key element. The accelKey is used as the key (when a string) or keycode (when a number) attribute. The accelModifiers is used as the modifiers attribute. The behavior is as described in Mozilla's documentation for these attributes.

Returns

undefined

Examples

GM_registerMenuCommand("Hello, world (simple)", helloSimple);
GM_registerMenuCommand("Hello, world!", hello, "e", "control", "h");
GM_registerMenuCommand("Hello, world! (again)", hello2, "e", "shift alt", "w");