GM.registerMenuCommand: Difference between revisions
From GreaseSpot Wiki
Jump to navigationJump to search
m Misc formatting and commenting |
m →Syntax: Monkey colored tables |
||
Line 16: | Line 16: | ||
:Compatibility: [[Version_history#0.2.5|Greasemonkey 0.2.5+]] | :Compatibility: [[Version_history#0.2.5|Greasemonkey 0.2.5+]] | ||
:{| | :{| cellpadding="5" style="border-style:solid; background:#FFFFE0;" | ||
|+ Parameters | |+ Parameters | ||
!|'''Properties''' || | !style="background:#CC9900;"|'''Properties''' || style="background:#CC9900;"|'''Event Handlers''' | ||
|- | |- | ||
| <code>[[#commandName |commandName]]</code> ||<code>[[#commandFunc|commandFunc]]</code> | | <code><span style="background:#FFFFE0;">[[#commandName |commandName]]</span></code> ||<code><span style="background:#FFFFE0;">[[#commandFunc|commandFunc]]</span></code> | ||
|- | |- | ||
|<code>[[#accelKey |accelKey]]</code> | |<code><span style="background:#FFFFE0;">[[#accelKey |accelKey]]</span></code> | ||
|- | |- | ||
|<code>[[#accelModifiers |accelModifiers]]</code> | |<code><span style="background:#FFFFE0;">[[#accelModifiers |accelModifiers]]</span></code> | ||
|- | |- | ||
|<code>[[#accessKey |accessKey]]</code> | |<code><span style="background:#FFFFE0;">[[#accessKey |accessKey]]</span></code> | ||
|} | |} | ||
:* All properties and event handlers are optional except [[#commandName|commandName]] and [[#commandFunc|commandFunc]]. | :* All properties and event handlers are optional except [[#commandName|commandName]] and [[#commandFunc|commandFunc]]. |
Revision as of 22:19, 11 December 2007
Description
This API method allows user scripts to add a menu command to the "User Script Commands" submenu.
Syntax
GM_registerMenuCommand( commandName, commandFunc, accelKey, accelModifiers, accessKey )
- Value: Function
- Returns: Nothing
- Compatibility: Greasemonkey 0.2.5+
Parameters Properties Event Handlers commandName
commandFunc
accelKey
accelModifiers
accessKey
- All properties and event handlers are optional except commandName and commandFunc.
Properties
commandName
- Value: String
- Usage:
commandName = "Some Name";
- Name to display in the "User Script Commands" submenu.
commandFunc
- Value: Function
- Usage:
commandFunc = function(){ /* some code */ };
- Function to call
accelKey
- Value: String
- Usage:
accelKey = "g";
- A single character or keycode that can trigger the command.
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.
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.
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 );