GM.registerMenuCommand: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
Marti (talk | contribs)
Marti (talk | contribs)
mNo edit summary
Line 30: Line 30:
:* 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]].


[[#Description|top]]
[[#top|top]]
=== Properties ===
=== Properties ===
----
----
Line 39: Line 39:
:* 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]].


[[#Description|top]] | [[#Syntax|back]]''
[[#top|top]] | [[#Syntax|back]]''


==== <code>commandFunc</code> ====
==== <code>commandFunc</code> ====
Line 47: Line 47:
:* Function to call
:* Function to call


[[#Description|top]] | [[#Syntax|back]]
[[#top|top]] | [[#Syntax|back]]


==== <code>accelKey</code> ====
==== <code>accelKey</code> ====
Line 55: Line 55:
:* A single character or keycode that can trigger the command.
:* A single character or keycode that can trigger the command.


[[#Description|top]] | [[#Syntax|back]]
[[#top|top]] | [[#Syntax|back]]


==== <code>accelModifiers</code> ====
==== <code>accelModifiers</code> ====
Line 63: Line 63:
:* 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.


[[#Description|top]] | [[#Syntax|back]]
[[#top|top]] | [[#Syntax|back]]


==== <code>accessKey</code> ====
==== <code>accessKey</code> ====
Line 71: Line 71:
:* 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]].


[[#Description|top]] | [[#Syntax|back]]
[[#top|top]] | [[#Syntax|back]]


== Examples ==
== Examples ==
Line 80: Line 80:
<code><pre>GM_registerMenuCommand( "Hello, world (simple)", helloSimple );</pre></code>
<code><pre>GM_registerMenuCommand( "Hello, world (simple)", helloSimple );</pre></code>


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


== Notes ==
== Notes ==


[[#Description|top]]
[[#top|top]]
[[Category:API_Reference|G]]
[[Category:API_Reference|G]]

Revision as of 09:15, 8 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 )

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