|
|
(36 intermediate revisions by 7 users not shown) |
Line 1: |
Line 1: |
| {{underscore|title=GM_registerMenuCommand}}
| | As of Greasemonkey 4.0, this method has been removed. |
| __NOTOC__
| | * See [https://wiki.greasespot.net/index.php?title=GM_registerMenuCommand&oldid=7473 history] for older versions. |
| | | * See the [https://github.com/greasemonkey/gm4-polyfill GM4 Polyfill] for a Greasemonkey 4 compatible way to get similar functionality. |
| == Description ==
| |
| | |
| This [[API_reference|API]] method allows user scripts to add a menu command to the [[Greasemonkey_Manual:Monkey_Menu#The_Menu|"User Script Commands" submenu]].
| |
| | |
| [[#Examples|Examples]] | [[#Notes|Notes]]
| |
| | |
| == Syntax ==
| |
| | |
| '''GM_registerMenuCommand(''' ''commandName'', ''commandFunc'', ''accelKey'', ''accelModifiers'', ''accessKey'' ''')'''
| |
| | |
| :Returns: Nothing | |
| :Compatibility: [[Version_history#0.2.5|Greasemonkey 0.2.5+]]
| |
| | |
| :{| border="1" cellpadding="5"
| |
| |+ Parameters
| |
| !|'''Properties''' || !|'''Event Handlers'''
| |
| |-
| |
| | <code>[[#commandName |commandName]]</code> ||<code>[[#commandFunc|commandFunc]]</code>
| |
| |-
| |
| |<code>[[#accelKey |accelKey]]</code>
| |
| |-
| |
| |<code>[[#accelModifiers |accelModifiers]]</code>
| |
| |-
| |
| |<code>[[#accessKey |accessKey]]</code>
| |
| |}
| |
| :* All properties and event handlers are optional except [[#commandName|commandName]] and [[#commandFunc|commandFunc]].
| |
| | |
| [[#Description|top]]
| |
| === Properties ===
| |
| ----
| |
| ==== <code>commandName</code> ====
| |
| :Value: String
| |
| :Usage: <code>commandName</code>
| |
| | |
| :* Name to display in the [[Greasemonkey_Manual:Monkey_Menu#The_Menu|"User Script Commands" submenu]].
| |
| | |
| [[#Description|top]] | [[#Syntax|back]]''
| |
| | |
| ==== <code>commandFunc</code> ====
| |
| :Value: Function
| |
| :Usage: <code>commandFunc = function(){ ''// Some code'' };</code>
| |
| | |
| :* Function to call | |
| | |
| [[#Description|top]] | [[#Syntax|back]]
| |
| | |
| ==== <code>accelKey</code> ====
| |
| :Value: String
| |
| :Usage: <code>accelKey = "g";</code>
| |
| | |
| :* A single character or keycode that can trigger the command.
| |
| | |
| [[#Description|top]] | [[#Syntax|back]]
| |
| | |
| ==== <code>accelModifiers</code> ====
| |
| :Value: String
| |
| :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.
| |
| | |
| [[#Description|top]] | [[#Syntax|back]]
| |
| | |
| ==== <code>accessKey</code> ====
| |
| :Value: String
| |
| :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]].
| |
| | |
| [[#Description|top]] | [[#Syntax|back]]
| |
| | |
| = Examples =
| |
| <code><pre>GM_registerMenuCommand( "Hello, world!", hello, "e", "control", "h" );</pre></code>
| |
| | |
| <code><pre>GM_registerMenuCommand( "Hello, world! (again)", hello2, "e", "shift alt", "w" );</pre></code>
| |
| | |
| <code><pre>GM_registerMenuCommand( "Hello, world (simple)", helloSimple );</pre></code>
| |
| | |
| [[#Description|top]]
| |
| | |
| = Notes =
| |
| | |
| [[#Description|top]]
| |
| [[Category:API_Reference|G]]
| |