Difference between revisions of "GM.registerMenuCommand"

From GreaseSpot Wiki
Jump to navigationJump to search
m
Line 34: Line 34:
==== <code>commandName</code> ====
==== <code>commandName</code> ====
:Value: String
:Value: String
:Usage: <code>commandName</code>
:Usage: <code>'''commandName''' = "Some Name"</code>


:* Name to display in the [[Greasemonkey_Manual:Monkey_Menu#The_Menu|"User Script Commands" submenu]].
:* Name to display in the [[Greasemonkey_Manual:Monkey_Menu#The_Menu|"User Script Commands" submenu]].
Line 42: Line 42:
==== <code>commandFunc</code> ====
==== <code>commandFunc</code> ====
:Value: Function
:Value: Function
:Usage: <code>commandFunc = function(){ ''// Some code'' };</code>
:Usage: <code>'''commandFunc''' = function(){ ''// Some code'' };</code>


:* Function to call
:* Function to call
Line 50: Line 50:
==== <code>accelKey</code> ====
==== <code>accelKey</code> ====
:Value: String
:Value: String
:Usage: <code>accelKey = "g";</code>
:Usage: <code>'''accelKey''' = "g";</code>


:* A single character or keycode that can trigger the command.
:* A single character or keycode that can trigger the command.
Line 58: Line 58:
==== <code>accelModifiers</code> ====
==== <code>accelModifiers</code> ====
:Value: String
:Value: String
:Usage: <code>accelModifiers = "control alt";</code>
:Usage: <code>'''accelModifiers''' = "control alt";</code>


:* A string listing modifiers that must be pressed with the [[#accelKey|accelKey]]. If there's more than one, then they should be separated with spaces. Available modifiers are: shift, alt, meta, control, and accel.
:* A string listing modifiers that must be pressed with the [[#accelKey|accelKey]]. If there's more than one, then they should be separated with spaces. Available modifiers are: shift, alt, meta, control, and accel.
Line 66: Line 66:
==== <code>accessKey</code> ====
==== <code>accessKey</code> ====
:Value: String
:Value: String
:Usage: <code>accessKey = "g";</code>
:Usage: <code>'''accessKey''' = "g";</code>


:* A single character that can be used to jump to the command when the menu is open. It should be a letter in [[#commandName|commandName]].
:* A single character that can be used to jump to the command when the menu is open. It should be a letter in [[#commandName|commandName]].

Revision as of 22:15, 6 December 2007

Template:Underscore


Description

This API method allows user scripts to add a menu command to the "User Script Commands" submenu.

Examples | Notes

Syntax

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

Returns: Nothing
Compatibility: Greasemonkey 0.2.5+
Parameters
Properties Event Handlers
commandName commandFunc
accelKey
accelModifiers
accessKey

top

Properties


commandName

Value: String
Usage: commandName = "Some Name"

top | back

commandFunc

Value: Function
Usage: commandFunc = function(){ // Some code };
  • Function to call

top | back

accelKey

Value: String
Usage: accelKey = "g";
  • A single character or keycode that can trigger the command.

top | back

accelModifiers

Value: String
Usage: accelModifiers = "control alt";
  • A string listing modifiers that must be pressed with the accelKey. If there's more than one, then they should be separated with spaces. Available modifiers are: shift, alt, meta, control, and accel.

top | back

accessKey

Value: String
Usage: accessKey = "g";
  • A single character that can be used to jump to the command when the menu is open. It should be a letter in commandName.

top | back

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

top

Notes

top