GM.registerMenuCommand

From GreaseSpot Wiki
Revision as of 17:23, 3 November 2006 by Arantius (talk | contribs) (Starting from: http://greasemonkey.mozdev.org/authoring.html)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Syntax

GM_registerMenuCommand( commandName, commandFunc, accelKey, accelModifiers, accessKey )

Description

Userscripts can call GM_registerMenuCommand to add a menu command to the "User Script Commands" submenu. The first two arguments are required; the others are optional.

commandName
Name to display in the menu
commandFunc
Function to call
accelKey
A single character (e.g. 'g') or keycode that can trigger the command
accelModifiers
A string listing modifiers that must be pressed with the accelKey. If there's more than one, then they should be separated with spaces. For example, 'shift' or 'ctrl alt'. Available modifiers are: shift, alt, meta, control, and accel.
accessKey
A single character (e.g. 'g') that can be used to jump to the command when the menu is open. It should be a letter in commandName

Examples

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