GM.registerMenuCommand: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
m Text replace - "{{Samp |1=<pre style="border: none; margin: inherit;">" to "<pre class='sample'>"
m Text replace - "</pre>}}" to "</pre>"
Line 69: Line 69:


== Examples ==
== Examples ==
<pre class='sample'>GM_registerMenuCommand("Hello, world (simple)", helloSimple);</pre>}}
<pre class='sample'>GM_registerMenuCommand("Hello, world (simple)", helloSimple);</pre>


<pre class='sample'>GM_registerMenuCommand("Hello, world!", hello, "e", "control", "h");</pre>}}
<pre class='sample'>GM_registerMenuCommand("Hello, world!", hello, "e", "control", "h");</pre>


<pre class='sample'>GM_registerMenuCommand("Hello, world! (again)", hello2, "e", "shift alt", "w");</pre>}}
<pre class='sample'>GM_registerMenuCommand("Hello, world! (again)", hello2, "e", "shift alt", "w");</pre>


[[Category:API_Reference|R]]
[[Category:API_Reference|R]]

Revision as of 21:59, 3 February 2010


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: undefined
Compatibility: Greasemonkey 0.2.5+
Parameters
Properties Event Handlers
commandName commandFunc
accelKey
accelModifiers
accessKey

Properties


commandName

Value: String
Usage: commandName = "Some Name";


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 (simple)", helloSimple);
GM_registerMenuCommand("Hello, world!", hello, "e", "control", "h");
GM_registerMenuCommand("Hello, world! (again)", hello2, "e", "shift alt", "w");