Scripting Menus » History » Version 44
  Per Amundsen, 11/22/2019 12:56 PM 
  
| 1 | 14 | Per Amundsen | {{>toc}} | 
|---|---|---|---|
| 2 | 1 | Per Amundsen | |
| 3 | 14 | Per Amundsen | h1. Scripting Menus | 
| 4 | |||
| 5 | 36 | Per Amundsen | You can edit most AdiIRC menus in the Menu Editor located at Menubar -> 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 | 32 | Per Amundsen | ChannelLink - Edit the channel link menus. (AdiIRC only) | 
| 13 | Link - Edit the regular link menus. (AdiIRC only) | ||
| 14 | 1 | Per Amundsen | |
| 15 | 21 | Per Amundsen | A menu syntax consists of <Menu text><colon><Menu command>. | 
| 16 | 1 | Per Amundsen | |
| 17 | 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. | ||
| 18 | |||
| 19 | 38 | Per Amundsen | _[[$chr|$chr(58)]] can be used to add a colon in most cases._ | 
| 20 | |||
| 21 | 1 | Per Amundsen | *Example* | 
| 22 | |||
| 23 | <pre> | ||
| 24 | ; 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. | ||
| 25 | Query:/query $1 | ||
| 26 | </pre> | ||
| 27 | |||
| 28 | 37 | Per Amundsen | Menu commands can also contain multiple lines, if so they must be enclosed with curly brackets. | 
| 29 | 22 | Per Amundsen | |
| 30 | *Example* | ||
| 31 | |||
| 32 | <pre> | ||
| 33 | ; Add a new menu item with the text "Query", when clicked, execute both "/query $1" and "/whois $1". | ||
| 34 | Query:{ | ||
| 35 | /query $1 | ||
| 36 | /whois $1 | ||
| 37 | } | ||
| 38 | </pre> | ||
| 39 | |||
| 40 | 40 | Per Amundsen | _See also [[$menu]], [[$menutype]], [[$menucontext]], [[$mouse]]._ | 
| 41 | |||
| 42 | 14 | Per Amundsen | h2. Menu prefix | 
| 43 | 9 | Per Amundsen | |
| 44 | 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. | 
| 45 | 1 | Per Amundsen | |
| 46 | *Example* | ||
| 47 | |||
| 48 | <pre> | ||
| 49 | 44 | Per Amundsen | ; Add a new menu item with the text "Whois", when clicked execute "/whois $1". | 
| 50 | 1 | Per Amundsen | menu nicklist { | 
| 51 | Whois:/whois $1 | ||
| 52 | } | ||
| 53 | </pre> | ||
| 54 | 9 | Per Amundsen | |
| 55 | 14 | Per Amundsen | h2. Target multiple menus | 
| 56 | 1 | Per Amundsen | |
| 57 | 11 | Per Amundsen | Multiple menus can be targeted with the same menu item by separating them with comma. | 
| 58 | 8 | Per Amundsen | |
| 59 | *Example* | ||
| 60 | |||
| 61 | <pre> | ||
| 62 | 44 | Per Amundsen | ; Add a new menu item for nicklist and channels with the text "Hello World", when clicked execute "/echo -ag Hello World". | 
| 63 | 8 | Per Amundsen | menu nicklist,channel { | 
| 64 | 24 | Per Amundsen | Hello World:/echo -ag Hello World | 
| 65 | 8 | Per Amundsen | } | 
| 66 | </pre> | ||
| 67 | |||
| 68 | 35 | Per Amundsen | [[Scripting_Wildcards|Wildcards]] can also be used. | 
| 69 | 20 | Per Amundsen | |
| 70 | *Example* | ||
| 71 | |||
| 72 | <pre> | ||
| 73 | ; Add a new menu item for all menus with the text "Hello World", when clicked execute "/echo -ag Hello World". | ||
| 74 | menu * { | ||
| 75 | 24 | Per Amundsen | Hello World:/echo -ag Hello World | 
| 76 | 20 | Per Amundsen | } | 
| 77 | |||
| 78 | ; Add a new menu item for all custom window menus with the text "Hello World", when clicked execute "/echo -ag Hello World". | ||
| 79 | menu @* { | ||
| 80 | 24 | Per Amundsen | Hello World:/echo -ag Hello World | 
| 81 | 20 | Per Amundsen | } | 
| 82 | </pre> | ||
| 83 | |||
| 84 | 14 | Per Amundsen | h2. Menu hierarchy | 
| 85 | 1 | Per Amundsen | |
| 86 | The menu hierarchy is determined by punctuation marks. | ||
| 87 | |||
| 88 | 10 | Per Amundsen | This works in both the Menu Editor and in a custom script using the Menu prefix. | 
| 89 | 1 | Per Amundsen | |
| 90 | *Example* | ||
| 91 | |||
| 92 | <pre> | ||
| 93 | menu nicklist { | ||
| 94 | 43 | Per Amundsen | ; Create a upper menu item called "Tools", notice you don't need a colon for the upper menu. | 
| 95 | 1 | Per Amundsen | Tools | 
| 96 | |||
| 97 | 43 | Per Amundsen | ; Use a punctuation mark to put a sub menu item inside "Tools" | 
| 98 | 1 | Per Amundsen | .Whois:/whois $1 | 
| 99 | |||
| 100 | 43 | Per Amundsen | ; Use a punctuation mark to put another sub menu item inside "Tools" | 
| 101 | 1 | Per Amundsen | .Who:/who $1 | 
| 102 | |||
| 103 | 43 | Per Amundsen | ; Create another upper menu item called "Operate" | 
| 104 | 1 | Per Amundsen | Operate | 
| 105 | |||
| 106 | 43 | Per Amundsen | ; Use a punctuation mark to put a sub menu item inside "Operate" | 
| 107 | 1 | Per Amundsen | .Kill:kill $1 | 
| 108 | |||
| 109 | 43 | Per Amundsen | ; Create a sub menu item called "Operate More" inside "Operate" | 
| 110 | 1 | Per Amundsen | .Operate More | 
| 111 | 13 | Per Amundsen | |
| 112 | 43 | Per Amundsen | ; Use two punctuation marks to put a sub menu item inside "Operate More" | 
| 113 | 1 | Per Amundsen | ..Kill again:kill $1 | 
| 114 | } | ||
| 115 | </pre> | ||
| 116 | 2 | Per Amundsen | |
| 117 | 14 | Per Amundsen | h2. Separator | 
| 118 | 6 | Per Amundsen | |
| 119 | 7 | Per Amundsen | Hyphen (-) can be used to add a menu separator. | 
| 120 | 6 | Per Amundsen | |
| 121 | *Example* | ||
| 122 | |||
| 123 | <pre> | ||
| 124 | menu nicklist { | ||
| 125 | 42 | Per Amundsen | ; Create a upper menu item called "Tools". | 
| 126 | 6 | Per Amundsen | Tools | 
| 127 | |||
| 128 | 42 | Per Amundsen | ; Add a separator. | 
| 129 | 1 | Per Amundsen | - | 
| 130 | |||
| 131 | 42 | Per Amundsen | ; Create another upper menu item called "More Tools". | 
| 132 | More Tools | ||
| 133 | |||
| 134 | ; Create a submenu. | ||
| 135 | .Submenu | ||
| 136 | |||
| 137 | ; Add a separator inside the submenu. | ||
| 138 | ; Separators need the same amount of punctuations "." as the submenu itself. | ||
| 139 | .- | ||
| 140 | |||
| 141 | ; Create another submenu. | ||
| 142 | .Submenu2 | ||
| 143 | 6 | Per Amundsen | } | 
| 144 | </pre> | ||
| 145 | |||
| 146 | 31 | Per Amundsen | h2. Merging menu items | 
| 147 | |||
| 148 | It's possible to merge menu items with other menu items using the same text. | ||
| 149 | |||
| 150 | *Example* | ||
| 151 | |||
| 152 | <pre> | ||
| 153 | ; Both "Apple" and "Banana" will be shown in the "Fruit" menu. | ||
| 154 | menu * { | ||
| 155 | Fruit | ||
| 156 | .Banana | ||
| 157 | } | ||
| 158 | |||
| 159 | menu * { | ||
| 160 | Fruit | ||
| 161 | .Apple | ||
| 162 | } | ||
| 163 | </pre> | ||
| 164 | 6 | Per Amundsen | |
| 165 | 16 | Per Amundsen | h2. $1- lines inside menus | 
| 166 | 2 | Per Amundsen | |
| 167 | $1- will be filled with different words depending on the menu type. | ||
| 168 | |||
| 169 | Status - The currently connected [[$network]] name. | ||
| 170 | Channel - The current [[$chan]] name. | ||
| 171 | Query - The [[$nick]] associated with the query window. | ||
| 172 | Nicklist - A list of selected nicks in the nicklist. | ||
| 173 | 4 | Per Amundsen | Menubar - Your nick ([[$me]]) on currently connected server. | 
| 174 | 41 | Per Amundsen | Custom Menubar Items - The name of the associated @popup menu. | 
| 175 | 17 | Per Amundsen | |
| 176 | h2. Adding top menus | ||
| 177 | |||
| 178 | 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. | 
| 179 | 17 | Per Amundsen | |
| 180 | 19 | Per Amundsen | Regular scripted menus can be used by referencing the @popup name, e.g "menu @mymenu { }" | 
| 181 | 25 | Per Amundsen | |
| 182 | h2. Mouse events | ||
| 183 | |||
| 184 | For [[/window|custom windows]] there are some special menu items which is triggered on various mouse events. | ||
| 185 | |||
| 186 | 26 | Per Amundsen | These menus must be at the start of the menu block. | 
| 187 | |||
| 188 | 25 | Per Amundsen | Syntax is the same as regular menus, but the menu name must be of the following: | 
| 189 | |||
| 190 | 28 | Per Amundsen | *Picture Windows* | 
| 191 | |||
| 192 | 25 | Per Amundsen | mouse - Triggers when the mouse moves. | 
| 193 | sclick - Triggers when the left mouse button is pressed down. | ||
| 194 | mclick - Triggers when the middle mouse button is pressed down. (AdiIRC only) | ||
| 195 | dclick - Triggers when the left mouse button is pressed down twice. | ||
| 196 | 27 | Per Amundsen | dmclick - Triggers when the middle mouse button is pressed down twice. (AdiIRC only) | 
| 197 | drclick - Triggers when the right mouse button is pressed down twice. (AdiIRC only) | ||
| 198 | 25 | Per Amundsen | uclick - Triggers when any mouse button is released. | 
| 199 | rclick - Triggers when the right mouse button is pressed down. | ||
| 200 | leave - Triggers when the mouse leaves the window. | ||
| 201 | 1 | Per Amundsen | drop - Triggers when the window receives a drag/drop event. | 
| 202 | 28 | Per Amundsen | |
| 203 | *Custom Windows text area* | ||
| 204 | |||
| 205 | 29 | Per Amundsen | rclick - Triggers when the right mouse button is pressed down. | 
| 206 | 28 | Per Amundsen | dclick - Triggers when the left mouse button is pressed down twice. | 
| 207 | dmclick - Triggers when the middle mouse button is pressed down twice. (AdiIRC only) | ||
| 208 | drclick - Triggers when the right mouse button is pressed down twice. (AdiIRC only) | ||
| 209 | |||
| 210 | *Custom Windows Nicklist* | ||
| 211 | |||
| 212 | lbclick - Triggers when the left mouse button is pressed down in the listbox. | ||
| 213 | rclick - Triggers when the right mouse button is pressed down. | ||
| 214 | dclick - Triggers when the left mouse button is pressed down twice. | ||
| 215 | dmclick - Triggers when the middle mouse button is pressed down twice. (AdiIRC only) | ||
| 216 | drclick - Triggers when the right mouse button is pressed down twice. (AdiIRC only) | ||
| 217 | 26 | Per Amundsen | |
| 218 | 30 | Per Amundsen | rclick and drclick only triggers when there is no right click menu or the right click menu has no items. | 
| 219 | |||
| 220 | 26 | Per Amundsen | *Example* | 
| 221 | |||
| 222 | <pre> | ||
| 223 | ; Create a custom window. | ||
| 224 | /window @test | ||
| 225 | |||
| 226 | ; Add a mouse menu. | ||
| 227 | menu @test { | ||
| 228 | slick:echo -ag Left mouse button was clicked. | ||
| 229 | rlick:echo -ag Right mouse button was clicked. | ||
| 230 | Menu:echo -ag Just a regular menu item. | ||
| 231 | } | ||
| 232 | </pre> | ||
| 233 | 33 | Per Amundsen | |
| 234 | h2. Menu styles | ||
| 235 | |||
| 236 | You can style menus with check mark and disable them using the [[$style]] identifier. | ||
| 237 | |||
| 238 | *Checked* | ||
| 239 | |||
| 240 | !checked.png! | ||
| 241 | <pre> | ||
| 242 | menu * { | ||
| 243 | Checked $style(1):noop | ||
| 244 | } | ||
| 245 | </pre> | ||
| 246 | |||
| 247 | *Disabled* | ||
| 248 | |||
| 249 | !disabled.png! | ||
| 250 | <pre> | ||
| 251 | menu * { | ||
| 252 | Disabled $style(2):noop | ||
| 253 | } | ||
| 254 | </pre> | ||
| 255 | |||
| 256 | 1 | Per Amundsen | *Checked and disabled* | 
| 257 | 34 | Per Amundsen | |
| 258 | !checked_and_disabled.png! | ||
| 259 | 33 | Per Amundsen | <pre> | 
| 260 | menu * { | ||
| 261 | Checked and disabled $style(3):noop | ||
| 262 | } | ||
| 263 | </pre> | ||
| 264 | |||
| 265 | h2. Menu icons | ||
| 266 | |||
| 267 | In AdiIRC it's also possible to add a icon to any menu item using the [[$menuicon]] identifier. | ||
| 268 | |||
| 269 | !icon.png! | ||
| 270 | <pre> | ||
| 271 | menu * { | ||
| 272 | Icon $menuicon($scriptdir\icon.ico):noop | ||
| 273 | } | ||
| 274 | </pre> | ||
| 275 | 39 | Per Amundsen | |
| 276 | h2. Dynamic sub menus | ||
| 277 | |||
| 278 | To dynamically create sub menus, the [[$submenu]] identifier can be used. | ||
| 279 | |||
| 280 | *Example* | ||
| 281 | |||
| 282 | <pre> | ||
| 283 | menu * { | ||
| 284 | Animal | ||
| 285 | .$submenu($animal($1)) | ||
| 286 | } | ||
| 287 | |||
| 288 | alias animal { | ||
| 289 | if ($1 == begin) return - | ||
| 290 | if ($1 == 1) return Dog:echo Dog | ||
| 291 | if ($1 == 2) return Cat:echo Cat | ||
| 292 | if ($1 == 3) return Bird:echo Bird | ||
| 293 | if ($1 == end) return - | ||
| 294 | } | ||
| 295 | </pre> |