Scripting Menus » History » Version 31
Per Amundsen, 02/25/2017 09:56 PM
| 1 | 14 | Per Amundsen | {{>toc}} |
|---|---|---|---|
| 2 | 1 | Per Amundsen | |
| 3 | 14 | Per Amundsen | h1. Scripting Menus |
| 4 | |||
| 5 | 5 | Per Amundsen | You can edit most AdiIRC menus in the Menu Editor located at Tools -> Edit Menus. |
| 6 | 1 | Per Amundsen | |
| 7 | Status - Edit the status menus. |
||
| 8 | Channel - Edit the channel menus. |
||
| 9 | Query - Edit the query menus. |
||
| 10 | Nicklist - Edit the nicklist menus. |
||
| 11 | Menubar - Edit the menubar menus. |
||
| 12 | |||
| 13 | 21 | Per Amundsen | A menu syntax consists of <Menu text><colon><Menu command>. |
| 14 | 1 | Per Amundsen | |
| 15 | For this reason, only one colon is allowed in a menu, neither the text nor the command can contain any other colons for the menu to work properly. |
||
| 16 | |||
| 17 | *Example* |
||
| 18 | |||
| 19 | <pre> |
||
| 20 | ; Add a new menu item with the text "Query", when clicked, execute "/query $1" where $1 means the first word given to this menu, usually a nick. |
||
| 21 | Query:/query $1 |
||
| 22 | </pre> |
||
| 23 | |||
| 24 | 22 | Per Amundsen | Menu commands can also contain multiple lines, if so they must be enclosed with brackets. |
| 25 | |||
| 26 | *Example* |
||
| 27 | |||
| 28 | <pre> |
||
| 29 | ; Add a new menu item with the text "Query", when clicked, execute both "/query $1" and "/whois $1". |
||
| 30 | Query:{ |
||
| 31 | /query $1 |
||
| 32 | /whois $1 |
||
| 33 | } |
||
| 34 | </pre> |
||
| 35 | |||
| 36 | 14 | Per Amundsen | h2. Menu prefix |
| 37 | 9 | Per Amundsen | |
| 38 | 23 | Per Amundsen | The "menu" prefix can also be used in a custom script to add more items to a menu, the syntax is the same. |
| 39 | 1 | Per Amundsen | |
| 40 | *Example* |
||
| 41 | |||
| 42 | <pre> |
||
| 43 | ;Add a new menu item with the text "Whois", when clicked execute "/whois $1". |
||
| 44 | menu nicklist { |
||
| 45 | Whois:/whois $1 |
||
| 46 | } |
||
| 47 | </pre> |
||
| 48 | 9 | Per Amundsen | |
| 49 | 14 | Per Amundsen | h2. Target multiple menus |
| 50 | 1 | Per Amundsen | |
| 51 | 11 | Per Amundsen | Multiple menus can be targeted with the same menu item by separating them with comma. |
| 52 | 8 | Per Amundsen | |
| 53 | *Example* |
||
| 54 | |||
| 55 | <pre> |
||
| 56 | ;Add a new menu item for nicklist and channels with the text "Hello World", when clicked execute "/echo -ag Hello World". |
||
| 57 | menu nicklist,channel { |
||
| 58 | 24 | Per Amundsen | Hello World:/echo -ag Hello World |
| 59 | 8 | Per Amundsen | } |
| 60 | </pre> |
||
| 61 | |||
| 62 | 20 | Per Amundsen | Wildcards can also be used. |
| 63 | |||
| 64 | *Example* |
||
| 65 | |||
| 66 | <pre> |
||
| 67 | ; Add a new menu item for all menus with the text "Hello World", when clicked execute "/echo -ag Hello World". |
||
| 68 | menu * { |
||
| 69 | 24 | Per Amundsen | Hello World:/echo -ag Hello World |
| 70 | 20 | Per Amundsen | } |
| 71 | |||
| 72 | ; Add a new menu item for all custom window menus with the text "Hello World", when clicked execute "/echo -ag Hello World". |
||
| 73 | menu @* { |
||
| 74 | 24 | Per Amundsen | Hello World:/echo -ag Hello World |
| 75 | 20 | Per Amundsen | } |
| 76 | </pre> |
||
| 77 | |||
| 78 | 14 | Per Amundsen | h2. Menu hierarchy |
| 79 | 1 | Per Amundsen | |
| 80 | The menu hierarchy is determined by punctuation marks. |
||
| 81 | |||
| 82 | 10 | Per Amundsen | This works in both the Menu Editor and in a custom script using the Menu prefix. |
| 83 | 1 | Per Amundsen | |
| 84 | *Example* |
||
| 85 | |||
| 86 | <pre> |
||
| 87 | menu nicklist { |
||
| 88 | ;Create a upper menu item called "Tools", notice you don't need a colon for the upper menu. |
||
| 89 | Tools |
||
| 90 | |||
| 91 | 13 | Per Amundsen | ;Use a punctuation mark to put a sub menu item inside "Tools" |
| 92 | 1 | Per Amundsen | .Whois:/whois $1 |
| 93 | |||
| 94 | 13 | Per Amundsen | ;Use a punctuation mark to put another sub menu item inside "Tools" |
| 95 | 1 | Per Amundsen | .Who:/who $1 |
| 96 | |||
| 97 | ;Create another upper menu item called "Operate" |
||
| 98 | Operate |
||
| 99 | |||
| 100 | 13 | Per Amundsen | ;Use a punctuation mark to put a sub menu item inside "Operate" |
| 101 | 1 | Per Amundsen | .Kill:kill $1 |
| 102 | |||
| 103 | ;Create a sub menu item called "Operate More" inside "Operate" |
||
| 104 | .Operate More |
||
| 105 | 13 | Per Amundsen | |
| 106 | 1 | Per Amundsen | ;Use two punctuation marks to put a sub menu item inside "Operate More" |
| 107 | ..Kill again:kill $1 |
||
| 108 | } |
||
| 109 | </pre> |
||
| 110 | 2 | Per Amundsen | |
| 111 | 14 | Per Amundsen | h2. Separator |
| 112 | 6 | Per Amundsen | |
| 113 | 7 | Per Amundsen | Hyphen (-) can be used to add a menu separator. |
| 114 | 6 | Per Amundsen | |
| 115 | *Example* |
||
| 116 | |||
| 117 | <pre> |
||
| 118 | menu nicklist { |
||
| 119 | ;Create a upper menu item called "Tools" |
||
| 120 | Tools |
||
| 121 | |||
| 122 | ;Add a separator |
||
| 123 | - |
||
| 124 | |||
| 125 | ;Create another upper menu item called "More Tools" |
||
| 126 | More Tools |
||
| 127 | } |
||
| 128 | </pre> |
||
| 129 | |||
| 130 | 31 | Per Amundsen | h2. Merging menu items |
| 131 | |||
| 132 | It's possible to merge menu items with other menu items using the same text. |
||
| 133 | |||
| 134 | *Example* |
||
| 135 | |||
| 136 | <pre> |
||
| 137 | ; Both "Apple" and "Banana" will be shown in the "Fruit" menu. |
||
| 138 | menu * { |
||
| 139 | Fruit |
||
| 140 | .Banana |
||
| 141 | } |
||
| 142 | |||
| 143 | menu * { |
||
| 144 | Fruit |
||
| 145 | .Apple |
||
| 146 | } |
||
| 147 | </pre> |
||
| 148 | 6 | Per Amundsen | |
| 149 | 16 | Per Amundsen | h2. $1- lines inside menus |
| 150 | 2 | Per Amundsen | |
| 151 | $1- will be filled with different words depending on the menu type. |
||
| 152 | |||
| 153 | Status - The currently connected [[$network]] name. |
||
| 154 | Channel - The current [[$chan]] name. |
||
| 155 | Query - The [[$nick]] associated with the query window. |
||
| 156 | Nicklist - A list of selected nicks in the nicklist. |
||
| 157 | 4 | Per Amundsen | Menubar - Your nick ([[$me]]) on currently connected server. |
| 158 | 17 | Per Amundsen | |
| 159 | h2. Adding top menus |
||
| 160 | |||
| 161 | 18 | Per Amundsen | As of AdiIRC 1.9.7 new top menus can be inserted in the Menubar after the "Help" item using the [[/menubar]] command. |
| 162 | 17 | Per Amundsen | |
| 163 | 19 | Per Amundsen | Regular scripted menus can be used by referencing the @popup name, e.g "menu @mymenu { }" |
| 164 | 25 | Per Amundsen | |
| 165 | h2. Mouse events |
||
| 166 | |||
| 167 | For [[/window|custom windows]] there are some special menu items which is triggered on various mouse events. |
||
| 168 | |||
| 169 | 26 | Per Amundsen | These menus must be at the start of the menu block. |
| 170 | |||
| 171 | 25 | Per Amundsen | Syntax is the same as regular menus, but the menu name must be of the following: |
| 172 | |||
| 173 | 28 | Per Amundsen | *Picture Windows* |
| 174 | |||
| 175 | 25 | Per Amundsen | mouse - Triggers when the mouse moves. |
| 176 | sclick - Triggers when the left mouse button is pressed down. |
||
| 177 | mclick - Triggers when the middle mouse button is pressed down. (AdiIRC only) |
||
| 178 | dclick - Triggers when the left mouse button is pressed down twice. |
||
| 179 | 27 | Per Amundsen | dmclick - Triggers when the middle mouse button is pressed down twice. (AdiIRC only) |
| 180 | drclick - Triggers when the right mouse button is pressed down twice. (AdiIRC only) |
||
| 181 | 25 | Per Amundsen | uclick - Triggers when any mouse button is released. |
| 182 | rclick - Triggers when the right mouse button is pressed down. |
||
| 183 | leave - Triggers when the mouse leaves the window. |
||
| 184 | 1 | Per Amundsen | drop - Triggers when the window receives a drag/drop event. |
| 185 | 28 | Per Amundsen | |
| 186 | *Custom Windows text area* |
||
| 187 | |||
| 188 | 29 | Per Amundsen | rclick - Triggers when the right mouse button is pressed down. |
| 189 | 28 | Per Amundsen | dclick - Triggers when the left mouse button is pressed down twice. |
| 190 | dmclick - Triggers when the middle mouse button is pressed down twice. (AdiIRC only) |
||
| 191 | drclick - Triggers when the right mouse button is pressed down twice. (AdiIRC only) |
||
| 192 | |||
| 193 | *Custom Windows Nicklist* |
||
| 194 | |||
| 195 | lbclick - Triggers when the left mouse button is pressed down in the listbox. |
||
| 196 | rclick - Triggers when the right mouse button is pressed down. |
||
| 197 | dclick - Triggers when the left mouse button is pressed down twice. |
||
| 198 | dmclick - Triggers when the middle mouse button is pressed down twice. (AdiIRC only) |
||
| 199 | drclick - Triggers when the right mouse button is pressed down twice. (AdiIRC only) |
||
| 200 | 26 | Per Amundsen | |
| 201 | 30 | Per Amundsen | rclick and drclick only triggers when there is no right click menu or the right click menu has no items. |
| 202 | |||
| 203 | 26 | Per Amundsen | *Example* |
| 204 | |||
| 205 | <pre> |
||
| 206 | ; Create a custom window. |
||
| 207 | /window @test |
||
| 208 | |||
| 209 | ; Add a mouse menu. |
||
| 210 | menu @test { |
||
| 211 | slick:echo -ag Left mouse button was clicked. |
||
| 212 | rlick:echo -ag Right mouse button was clicked. |
||
| 213 | Menu:echo -ag Just a regular menu item. |
||
| 214 | } |
||
| 215 | </pre> |