GM.registerMenuCommand: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
Marti (talk | contribs)
m →‎Syntax: swap to JavaScript return type
Marti (talk | contribs)
m marking core sample code vs other sample code
Line 75: Line 75:


== Examples ==
== Examples ==
<code><pre>GM_registerMenuCommand( "Hello, world!", hello, "e", "control", "h" );</pre></code>
{{Core samp |1=<pre style="border: none; margin: inherit;">GM_registerMenuCommand("Hello, world (simple)", helloSimple);</pre>}}


<code><pre>GM_registerMenuCommand( "Hello, world! (again)", hello2, "e", "shift alt", "w" );</pre></code>
{{Core samp |1=<pre style="border: none; margin: inherit;">GM_registerMenuCommand("Hello, world!", hello, "e", "control", "h");</pre>}}
 
{{Core samp |1=<pre style="border: none; margin: inherit;">GM_registerMenuCommand("Hello, world! (again)", hello2, "e", "shift alt", "w");</pre>}}


<code><pre>GM_registerMenuCommand( "Hello, world (simple)", helloSimple );</pre></code>


[[#top|top]]
[[#top|top]]

Revision as of 05:08, 7 May 2009

Template:Underscore


Greasemonkey Manual
Using Greasemonkey
Installing Scripts
Monkey Menu
Getting Help
User Script Authoring
Editing
Environment
API

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 )

Value: Function
Returns: undefined
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

Template:Core samp

Template:Core samp

Template:Core samp


top

Notes

top