svghmi/gen_index_xhtml.xslt
branchsvghmi
changeset 2934 ee483e8346f5
parent 2933 ed3f712a8eef
child 2936 53fb11263ff1
--- a/svghmi/gen_index_xhtml.xslt	Tue Apr 14 22:08:52 2020 +0200
+++ b/svghmi/gen_index_xhtml.xslt	Tue Apr 14 23:04:54 2020 +0200
@@ -905,11 +905,21 @@
 </xsl:text>
     <xsl:text>    set_selection: function(value) {
 </xsl:text>
-    <xsl:text>        this.text_elt.firstElementChild.textContent = 
-</xsl:text>
-    <xsl:text>          (value &gt;= 0 &amp;&amp; value &lt; this.content.length) ?
-</xsl:text>
-    <xsl:text>            this.content[value] : "?"+String(value)+"?";
+    <xsl:text>        let display_str;
+</xsl:text>
+    <xsl:text>        if(value &gt;= 0 &amp;&amp; value &lt; this.content.length){
+</xsl:text>
+    <xsl:text>            display_str = this.content[value];
+</xsl:text>
+    <xsl:text>            this.last_selection = value;
+</xsl:text>
+    <xsl:text>        } else {
+</xsl:text>
+    <xsl:text>            display_str = "?"+String(value)+"?";
+</xsl:text>
+    <xsl:text>        }
+</xsl:text>
+    <xsl:text>        this.text_elt.firstElementChild.textContent = display_str;
 </xsl:text>
     <xsl:text>    },
 </xsl:text>
@@ -1131,6 +1141,18 @@
 </xsl:text>
     <xsl:text>        } else {
 </xsl:text>
+    <xsl:text>            // align to selection
+</xsl:text>
+    <xsl:text>            let offset = this.last_selection - this.lift;
+</xsl:text>
+    <xsl:text>            if(offset &gt; 0)
+</xsl:text>
+    <xsl:text>                this.menu_offset = Math.min(offset + 1, length - slots + 1);
+</xsl:text>
+    <xsl:text>            else
+</xsl:text>
+    <xsl:text>                this.menu_offset = 0;
+</xsl:text>
     <xsl:text>            this.set_partial_text();
 </xsl:text>
     <xsl:text>        }