This section describes how you can integrate your macros into K-Meleon's user interfaces in order to allow the user to invoke your macros and how your macros can dynamically interact with these interfaces.
setaccel(<keys>[,<command>]);
This method can be used to set keyboard accelerators instead of editing accel.cfg.
Parameters:
| Parameter | Required | Type | Value | Meaning |
|---|---|---|---|---|
| <keys> | YES | STRING | A key combination(1) | The addressed key combination. |
| <command> | YES | STRING | A command(2) | The command to be associated with the addressed key combination. |
(1) A space-separated list of predefined key names.
(2) <command> can be "ID_..." or "<pluginName>(<pluginCommand>)". If <command> is an empty string, this is a deletion.
menu=<string expression>;
This statement is used inside a macro to set a label for this macro's menu representations. The label is statically set according to the value of the string expression. The latter is evaluated once when the menus are built.
Note that local variables are out of scope here, only globally defined variables can be used.
menuchecked=<boolean expression>;
This statement is used inside a macro to set a checkmark for this macro's menu representations. The checkmark's state is dynamically updated according to the value of the boolean expression. The latter is evaluated whenever a menu item representing this macro becomes visible.
Note that local variables are out of scope here, only globally defined variables can be used.
Use this statement in favor of an event based usage of the setcheck() statement.
menugrayed=<boolean expression>;
This statement is used inside a macro to enable and disable (gray out) this macro's menu representations. The enabled/disabled state is dynamically updated according to the value of the boolean expression. The latter is evaluated whenever a menu item representing this macro becomes visible.
Note that local variables are out of scope here, only globally defined variables can be used.
rebuildmenu(<menuName>);
This method is used to rebuild a menu that was created by a setmenu() statement. Note that a menu must be rebuilt by rebuildmenu() inside the same macro where it was built by setmenu(). The rebuildmenu() statement takes effect only when the hosting macro is (directly or indirectly) called from the menus. See proxy.kmm for a usage demonstration.
Parameters:
| Parameter | Required | Type | Value | Meaning |
|---|---|---|---|---|
| <menuName> | YES | STRING | A menu name | The name of the menu to be rebuilt. |
setcheck(<command>,<state>);
This method is used to set a checkmark for a certain command's menu representations. Use the menuchecked statement to handle checkmarks of menu items representing macros.
Parameters:
| Parameter | Required | Type | Value | Meaning |
|---|---|---|---|---|
| <command> | YES | STRING | A command | The command associated with the addressed menu items. |
| <state> | YES | BOOL | A boolean expression | The checkmark's state (true=visible, false=hidden). |
setmenu(<menuName>,<itemType>[,<itemName>[,<command>]][,<location>]);
This method can be used to insert and delete menu items instead of editing menus.cfg. Note that menus can be created OnInit and OnSetup only. Menus created by setmenu() can be modified later using the rebuildmenu() statement.
Parameters:
| Parameter | Required | Type | Value | Meaning |
|---|---|---|---|---|
| <menuName> | YES | STRING | A menu name(1) | The name of the addressed menu (that is the addressed item's parent menu). |
| <itemType> | YES | PREDEFINED | inline | Address an inline menu. |
| popup | Address a popup menu. | |||
| separator | Address a menu separator. | |||
| command | Address an item with a command or a macro associated to it. | |||
| macro | ||||
| <itemName> | NO(2) | STRING | An item name | The name of the addressed item inside the addressed menu. |
| <command> | NO(3) | STRING | A command | The command (to be) associated with the addressed item. |
| <location> | NO(4) | STRING | An item name or a command | Insert before the matching item. |
| INT | -1 (default) | Insert at the end of the addressed menu. | ||
| n=0,1,2,... | Insert at position n of the addressed menu (zero-based index). |
(1) An empty string specifies the menu root. Address the menu root when you want to create a popup menu (of type inline!) for a toolbar button that is not intended for use in other menus.
(2) <itemName> must be specified for all values of <itemType> except separator. If <itemName> is an empty string, this is a deletion.
(3) <command> must be specified for the values command and macro of <itemType>. For <itemType>=command <command> can be "ID_..." or "<pluginName>(<pluginCommand>)". For <itemType>=macro <command> must be a macro name. If <command> is an empty string and <itemName> is not, this is a deletion.
(4) <location> can be omitted for all values of <itemType> except separator (-1 is the default value).
Note that <menuName> and <itemName> are translated automatically if possible. In regard to the browser's startup performance, do not use the _() statement in conjunction with setmenu().