GM.registerMenuCommand: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
m (categorized)
(→‎Description: Changed "ctrl alt" to "control alt")
Line 13: Line 13:
; commandFunc : Function to call
; commandFunc : Function to call
; accelKey : A single character (e.g. 'g') or keycode that can trigger the command
; 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, <code>'shift'</code> or <code>'ctrl alt'</code>. Available modifiers are: shift, alt, meta, control, and accel.
; 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, <code>'shift'</code> or <code>'control alt'</code>. 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
; 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



Revision as of 11:50, 11 June 2007

Template:Underscore

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 'control 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 );