Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
module:ddlightbarmenu.js [2018/03/24 16:10] – Created a documentation page for load/DDLightbarMenu.js as a developer reference. nightfox | module:ddlightbarmenu.js [2019/05/09 02:40] (current) – removed digital man | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== DDLightbarMenu.js ====== | ||
- | DDLightbarMenu.js is a loadable JavaScript file that provides a lightbar menu class for use in JavaScript scripts for Synchronet. | ||
- | \\ | ||
- | The user can naviate the list using the up & down arrows, PageUp, PageDown, Home, and End keys. The enter key selects an item. The ESC key will exit the menu and return null. This menu library requires the use of an ANSI terminal. | ||
- | |||
- | This script provides an object, DDLightbarMenu. | ||
- | * Add() | ||
- | * SetItemHotkey() | ||
- | * AddItemHotkey() | ||
- | * SetPos() | ||
- | * SetSize() | ||
- | * GetVal() | ||
- | |||
- | To change the colors used for displaying the items, you can change the values in the colors object within the DDLightbarMenu object. | ||
- | * itemColor: The color to use for non-selected items (current default is white on blue) | ||
- | * selectedItemColor: | ||
- | * itemTextCharHighlightColor: | ||
- | * borderColor: | ||
- | |||
- | By default, the menu selection will wrap around to the beginning/ | ||
- | |||
- | This menu object supports adding multiple hotkeys to each menu item. A hotkey can be specified in the Add() method a couple of different ways - By specifying a hotkey as the 3rd parameter and/or by putting a & in the menu item text just before a key you want to use as the hotkey. | ||
- | lbMenu.ampersandHotkeysInItems = false; | ||
- | Note that ampersandHotkeysInItems must be set before adding menu items. | ||
- | |||
- | You can call the SetItemHotkey() method to set a single hotkey to be used for a menu item or AddItemHotkey() to add an additional hotkey for an item in addition to any existing hotkeys it might already have. | ||
- | |||
- | This menu class also supports an optional " | ||
- | lbMenu.numberedMode = true; | ||
- | When numbered mode is enabled and the user starts typing a number, the menu will prompt the user for an item number. | ||
- | |||
- | This menu also supports multiple options selected (by default, that is not enabled). | ||
- | lbMenu.multiSelect = true; | ||
- | lbMenu.maxNumSelections = 5; | ||
- | |||
- | Example usage: | ||
- | load(" | ||
- | // Create a menu at position 1, 3 with width 45 and height of 10 | ||
- | var lbMenu = new DDLightbarMenu(1, | ||
- | // Add 12 items to the menu, each of which will return the text of the item | ||
- | for (var i = 0; i < 12; ++i) | ||
- | lbMenu.Add(" | ||
- | // Set up the hotkey " | ||
- | lbMenu.SetItemHotkey(1, | ||
- | // Show the menu and get the chosen item from the user | ||
- | var val = lbMenu.GetVal(); | ||
- | // Output the chosen menu item | ||
- | console.print(" | ||
- | console.print(" | ||
- | console.pause(); | ||
- | | ||
- | // Changing the normal item color to green & selected item color to bright green: | ||
- | lbMenu.colors.itemColor = " | ||
- | lbMenu.colors.selectedItemColor = " | ||
- | | ||
- | // Disabling the navigation wrap behavior: | ||
- | lbMenu.wrapNavigation = false; | ||
- | | ||
- | // If you want a particular character in an item's text highlighted with | ||
- | // a different color, you can put a & character immediately before it, as | ||
- | // long as it's not a space. | ||
- | lbMenu.Add(" | ||
- | |||
- | To enable borders, set the borderEnabled property to true. Example: | ||
- | lbMenu.borderEnabled = true; | ||
- | |||
- | The menu object has an object called borderChars, | ||
- | * upperLeft: The character to use for the upper-left corner | ||
- | * upperRight: The character to use for the upper-right corner | ||
- | * lowerLeft: The character to use for the lower-left corner | ||
- | * lowerRight: The character to use for the lower-right corner | ||
- | * top: The character to use for the top border | ||
- | * bottom: The character to use for the bottom border | ||
- | * left: The character to use for the left border | ||
- | * right: The character to use for the right border | ||
- | For example: | ||
- | lbMenu.borderChars.upperLeft = " | ||
- | |||
- | If you want hotkeys to be case-sensitive, | ||
- | lbMenu.hotkeyCaseSensitive = true; | ||
- | |||
- | ===== See Also ===== | ||
- | * [[: | ||
- | |||
- | {{tag>}} | ||