Synchronet v3.19b-Win32 (install) has been released (Jan-2022).

You can donate to the Synchronet project using PayPal.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
custom:javascript:lib:ddlightbarmenu.js [2018/12/27 21:05] – DDLightbarMenu.js was renamed to dd_lightbar_menu.js nightfoxcustom:javascript:lib:ddlightbarmenu.js [2020/04/01 11:49] – Added information about the scrollbar feature nightfox
Line 2: Line 2:
 dd_lightbar_menu.js is a loadable JavaScript file that provides a lightbar menu class for use in JavaScript scripts for Synchronet.  The DDLightbarMenu class supports single item selection and multiple item selection.  For one example of how to use DDLightbarMenu, you can look at the code for ''[[howto:door:slyvote]]''.\\ dd_lightbar_menu.js is a loadable JavaScript file that provides a lightbar menu class for use in JavaScript scripts for Synchronet.  The DDLightbarMenu class supports single item selection and multiple item selection.  For one example of how to use DDLightbarMenu, you can look at the code for ''[[howto:door:slyvote]]''.\\
 \\ \\
-The user can navigate 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.  By default, this menu library does not display a border around the menu.  If you want this library to draw a border around the menu, you can set the borderEnabled property to true.  Without a border, the menu gains 2 characters of width and 2 lines of height.+The user can navigate 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.  By default, this menu library does not display a border around the menu.  If you want this library to draw a border around the menu, you can set the borderEnabled property to true.  Without a border, the menu gains 2 characters of width and 2 lines of height.  Also, a scrollbar can be optionally displayed, which provides a visual indicator for how far the user is through the list of items.  The scrollbar is disabled by default.
  
 dd_lightbar_menu.js provides a class, DDLightbarMenu.  To create a new DDLightbarMenu object: new DDLightbarMenu(x, y, width, height); dd_lightbar_menu.js provides a class, DDLightbarMenu.  To create a new DDLightbarMenu object: new DDLightbarMenu(x, y, width, height);
Line 32: Line 32:
 | colors                       | object | An object that contains color codes (as strings) for various things.  Contains the following properties: itemColor, selectedItemColor, itemTextCharHighlightColor, borderColor | | colors                       | object | An object that contains color codes (as strings) for various things.  Contains the following properties: itemColor, selectedItemColor, itemTextCharHighlightColor, borderColor |
 | borderEnabled                | boolean | Whether or not to draw a border around the menu items | | borderEnabled                | boolean | Whether or not to draw a border around the menu items |
 +| scrollbarEnabled             | boolean | Whether or not to enable the scrollbar.  Defaults to false. |
 | wrapNavigation               | boolean | Whether or not to wrap around to the beginning/end when using the down/up arrows.  Defaults to true. | | wrapNavigation               | boolean | Whether or not to wrap around to the beginning/end when using the down/up arrows.  Defaults to true. |
 | hotkeyCaseSensitive          | boolean | Whether or not hotkeys are case-sensitive.  Defaults to false. | | hotkeyCaseSensitive          | boolean | Whether or not hotkeys are case-sensitive.  Defaults to false. |
Line 46: Line 47:
 | itemTextCharHighlightColor | The color of a highlighted non-space character in an item text (specified by having a & in the item text).  It's important not to specify a "\1n" in here in case the item text should have a background color. | | itemTextCharHighlightColor | The color of a highlighted non-space character in an item text (specified by having a & in the item text).  It's important not to specify a "\1n" in here in case the item text should have a background color. |
 | borderColor                | The color for the borders (if borders are enabled) | | borderColor                | The color for the borders (if borders are enabled) |
 +| topBorderText              | Text to write in the top border (if borders are enabled).  This defaults to an empty string.  Synchronet color/attribute codes are supported. |
 +| bottomBorderText           | Text to write in the bottom border (if borders are enabled).  This defaults to an empty string.  Synchronet color/attribute codes are supported. |
  
 By default, the menu selection will wrap around to the beginning/end when using the down/up arrows.  That behavior can be disabled by setting the wrapNavigation property to false. By default, the menu selection will wrap around to the beginning/end when using the down/up arrows.  That behavior can be disabled by setting the wrapNavigation property to false.
Line 90: Line 93:
   // long as it's not a space.  For instance, to highlight the "x" in "Exit":   // long as it's not a space.  For instance, to highlight the "x" in "Exit":
   lbMenu.Add("E&xit", -1);   lbMenu.Add("E&xit", -1);
 +  
 +  // To enable borders and set text to display in the top & bottom borders:
 +  lbMenu.borderEnabled = true;
 +  lbMenu.topBorderText = "Options";
 +  lbMenu.bottomBorderText = "ESC: Quit";
  
 To enable borders, set the borderEnabled property to true.  Example: To enable borders, set the borderEnabled property to true.  Example:
   lbMenu.borderEnabled = true;   lbMenu.borderEnabled = true;
 +
 +To enable the scrollbar, set the scrollbarEnabled property to true.  Example:
 +  lbMenu.scrollbarEnabled = true;
 +If borders are enabled, the scrollbar will appear just inside the right border. Also, if the scrollbar is enabled but all the items would fit in a single "page" in the menu, then the scrollbar won't be displayed.\\ 
 +The scrollbar uses block characters to draw the scrollbar: ASCII character 176 for the background and ASCII 177 for the block that moves on the scrollbar.  If you want to change those characters, you can change the scrollbarInfo.BGChar and scrollbarInfo.blockChar properties in the menu object.\\ 
 +By default, the scrollbar colors are high (bright) black for the background and high (bright) white for the moving block character.  If desired, those can be changed with the colors.scrollbarBGColor and colors.scrollbarScrollBlockColor properties in the menu object.
  
 The menu object has an object called borderChars, which stores the characters used to draw the border.  you can change the characters used to draw the border by setting the following properties of the borderChars object: The menu object has an object called borderChars, which stores the characters used to draw the border.  you can change the characters used to draw the border by setting the following properties of the borderChars object: