Project

General

Profile

Scripting Menus » History » Revision 41

Revision 40 (Per Amundsen, 12/31/2018 11:39 AM) → Revision 41/52 (Per Amundsen, 05/03/2019 03:30 PM)

{{>toc}} 

 h1. Scripting Menus 

 You can edit most AdiIRC menus in the Menu Editor located at Menubar -> Tools -> Edit Menus. 

 Status - Edit the status menus. 
 Channel - Edit the channel menus. 
 Query - Edit the query menus. 
 Nicklist - Edit the nicklist menus. 
 Menubar - Edit the menubar menus. 
 ChannelLink - Edit the channel link menus. (AdiIRC only) 
 Link - Edit the regular link menus. (AdiIRC only) 

 A menu syntax consists of <Menu text><colon><Menu command>. 

 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. 

 _[[$chr|$chr(58)]] can be used to add a colon in most cases._ 

 *Example* 

 <pre> 
 ; 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. 
 Query:/query $1 
 </pre> 

 Menu commands can also contain multiple lines, if so they must be enclosed with curly brackets. 

 *Example* 

 <pre> 
 ; Add a new menu item with the text "Query", when clicked, execute both "/query $1" and "/whois $1". 
 Query:{ 
   /query $1 
   /whois $1 
 } 
 </pre> 

 _See also [[$menu]], [[$menutype]], [[$menucontext]], [[$mouse]]._ 

 h2. Menu prefix 

 The "menu" prefix can also be used in a custom script to add more items to a menu, the syntax is the same. 

 *Example* 

 <pre> 
 ;Add a new menu item with the text "Whois", when clicked execute "/whois $1". 
 menu nicklist { 
   Whois:/whois $1 
 } 
 </pre> 

 h2. Target multiple menus 

 Multiple menus can be targeted with the same menu item by separating them with comma. 

 *Example* 

 <pre> 
 ;Add a new menu item for nicklist and channels with the text "Hello World", when clicked execute "/echo -ag Hello World". 
 menu nicklist,channel { 
   Hello World:/echo -ag Hello World 
 } 
 </pre> 

 [[Scripting_Wildcards|Wildcards]] can also be used. 

 *Example* 

 <pre> 
 ; Add a new menu item for all menus with the text "Hello World", when clicked execute "/echo -ag Hello World". 
 menu * { 
   Hello World:/echo -ag Hello World 
 } 

 ; Add a new menu item for all custom window menus with the text "Hello World", when clicked execute "/echo -ag Hello World". 
 menu @* { 
   Hello World:/echo -ag Hello World 
 } 
 </pre> 

 h2. Menu hierarchy 

 The menu hierarchy is determined by punctuation marks. 

 This works in both the Menu Editor and in a custom script using the Menu prefix. 

 *Example* 

 <pre> 
 menu nicklist { 
   ;Create a upper menu item called "Tools", notice you don't need a colon for the upper menu. 
   Tools 

   ;Use a punctuation mark to put a sub menu item inside "Tools" 
   .Whois:/whois $1 

   ;Use a punctuation mark to put another sub menu item inside "Tools" 
   .Who:/who $1 

   ;Create another upper menu item called "Operate" 
   Operate 

   ;Use a punctuation mark to put a sub menu item inside "Operate" 
   .Kill:kill $1 

   ;Create a sub menu item called "Operate More" inside "Operate" 
   .Operate More 

   ;Use two punctuation marks to put a sub menu item inside "Operate More" 
   ..Kill again:kill $1 
 } 
 </pre> 

 h2. Separator 

 Hyphen (-) can be used to add a menu separator. 

 *Example* 

 <pre> 
 menu nicklist { 
   ;Create a upper menu item called "Tools" 
   Tools 

   ;Add a separator 
   - 

   ;Create another upper menu item called "More Tools" 
   More Tools 
 } 
 </pre> 

 h2. Merging menu items 

 It's possible to merge menu items with other menu items using the same text. 

 *Example* 

 <pre> 
 ; Both "Apple" and "Banana" will be shown in the "Fruit" menu. 
 menu * { 
   Fruit 
   .Banana 
 } 

 menu * { 
   Fruit 
   .Apple 
 } 
 </pre> 

 h2. $1- lines inside menus 

 $1- will be filled with different words depending on the menu type. 

 Status - The currently connected [[$network]] name. 
 Channel - The current [[$chan]] name. 
 Query - The [[$nick]] associated with the query window. 
 Nicklist - A list of selected nicks in the nicklist. 
 Menubar - Your nick ([[$me]]) on currently connected server. 
 Custom Menubar Items - The name of the associated @popup menu. 

 h2. Adding top menus 

 As of AdiIRC 1.9.7 new top menus can be inserted in the Menubar after the "Help" item using the [[/menubar]] command. 

 Regular scripted menus can be used by referencing the @popup name, e.g "menu @mymenu { }" 

 h2. Mouse events 

 For [[/window|custom windows]] there are some special menu items which is triggered on various mouse events. 

 These menus must be at the start of the menu block. 

 Syntax is the same as regular menus, but the menu name must be of the following: 

 *Picture Windows* 

 mouse - Triggers when the mouse moves. 
 sclick - Triggers when the left mouse button is pressed down. 
 mclick - Triggers when the middle mouse button is pressed down. (AdiIRC only) 
 dclick - Triggers when the left mouse button is pressed down twice. 
 dmclick - Triggers when the middle mouse button is pressed down twice. (AdiIRC only) 
 drclick - Triggers when the right mouse button is pressed down twice. (AdiIRC only) 
 uclick - Triggers when any mouse button is released. 
 rclick - Triggers when the right mouse button is pressed down. 
 leave - Triggers when the mouse leaves the window. 
 drop - Triggers when the window receives a drag/drop event. 

 *Custom Windows text area* 

 rclick - Triggers when the right mouse button is pressed down. 
 dclick - Triggers when the left mouse button is pressed down twice. 
 dmclick - Triggers when the middle mouse button is pressed down twice. (AdiIRC only) 
 drclick - Triggers when the right mouse button is pressed down twice. (AdiIRC only) 

 *Custom Windows Nicklist* 

 lbclick - Triggers when the left mouse button is pressed down in the listbox. 
 rclick - Triggers when the right mouse button is pressed down. 
 dclick - Triggers when the left mouse button is pressed down twice. 
 dmclick - Triggers when the middle mouse button is pressed down twice. (AdiIRC only) 
 drclick - Triggers when the right mouse button is pressed down twice. (AdiIRC only) 

 rclick and drclick only triggers when there is no right click menu or the right click menu has no items. 

 *Example* 

 <pre> 
 ; Create a custom window. 
 /window @test 

 ; Add a mouse menu. 
 menu @test { 
   slick:echo -ag Left mouse button was clicked. 
   rlick:echo -ag Right mouse button was clicked. 
   Menu:echo -ag Just a regular menu item. 
 } 
 </pre> 

 h2. Menu styles 

 You can style menus with check mark and disable them using the [[$style]] identifier. 

 *Checked* 

 !checked.png! 
 <pre> 
 menu * { 
   Checked $style(1):noop 
 } 
 </pre> 

 *Disabled* 

 !disabled.png! 
 <pre> 
 menu * { 
   Disabled $style(2):noop 
 } 
 </pre> 

 *Checked and disabled* 

 !checked_and_disabled.png! 
 <pre> 
 menu * { 
   Checked and disabled $style(3):noop 
 } 
 </pre> 

 h2. Menu icons 

 In AdiIRC it's also possible to add a icon to any menu item using the [[$menuicon]] identifier. 

 !icon.png! 
 <pre> 
 menu * { 
   Icon $menuicon($scriptdir\icon.ico):noop 
 } 
 </pre> 

 h2. Dynamic sub menus 

 To dynamically create sub menus, the [[$submenu]] identifier can be used. 

 *Example* 

 <pre> 
 menu * { 
  Animal 
  .$submenu($animal($1)) 
 } 

 alias animal { 
  if ($1 == begin) return - 
  if ($1 == 1) return Dog:echo Dog 
  if ($1 == 2) return Cat:echo Cat 
  if ($1 == 3) return Bird:echo Bird 
  if ($1 == end) return - 
 } 
 </pre>