svghmi/widget_dropdown.ysl2
branchsvghmi
changeset 3241 fe945f1f48b7
parent 3232 7bdb766c2a4d
child 3320 9fe5b4a04acc
equal deleted inserted replaced
3238:8a9d4c794cba 3241:fe945f1f48b7
     1 // widget_dropdown.ysl2
     1 // widget_dropdown.ysl2
       
     2 
       
     3 widget_desc("DropDown") {
       
     4 
       
     5     longdesc
       
     6     ||
       
     7     DropDown widget let user select an entry in a list of texts, given as
       
     8     arguments. Single variable path is index of selection.
       
     9 
       
    10     It needs "text" (svg:text), "box" (svg:rect), "button" (svg:*),
       
    11     and "highlight" (svg:rect) labeled elements.
       
    12 
       
    13     When user clicks on "button", "text" is duplicated to display enties in the
       
    14     limit of available space in page, and "box" is extended to contain all
       
    15     texts. "highlight" is moved over pre-selected entry.
       
    16 
       
    17     When only one argument is given, and argment contains "#langs" then list of
       
    18     texts is automatically set to the list of human-readable languages supported
       
    19     by this HMI. 
       
    20     ||
       
    21 
       
    22     shortdesc > Let user select text entry in a drop-down menu
       
    23 
       
    24     arg name="entries" count="many" accepts="string" > drop-down menu entries
       
    25 
       
    26     path name="selection" accepts="HMI_INT" > selection index
       
    27 }
       
    28 
       
    29 // TODO: support i18n of menu entries using svg:text elements with labels starting with "_"
     2 
    30 
     3 widget_class("DropDown") {
    31 widget_class("DropDown") {
     4 ||
    32 ||
     5         dispatch(value) {
    33         dispatch(value) {
     6             if(!this.opened) this.set_selection(value);
    34             if(!this.opened) this.set_selection(value);
   330         }
   358         }
   331 ||
   359 ||
   332 }
   360 }
   333 
   361 
   334 widget_defs("DropDown") {
   362 widget_defs("DropDown") {
   335     param "hmi_element";
       
   336     labels("text box button highlight");
   363     labels("text box button highlight");
   337     // It is assumed that list content conforms to Array interface.
   364     // It is assumed that list content conforms to Array interface.
   338     >   content:
   365     >   content:
   339     choose{
   366     choose{
   340         // special case when used for language selection
   367         // special case when used for language selection