# HG changeset patch # User Edouard Tisserant <edouard.tisserant@gmail.com> # Date 1613939924 -3600 # Node ID 99ce78ddd353db67ee33c8d0c9f9ff213f4a604a # Parent a8c81a080588db1f39de45a08a7193fbcbb7db2a SVGHMI: finally found why HMI:Input wasnt't initializing properly: vsprintf takes a list. Also, removed intermediate variable last_val, since edit_value() works on strings anyhow, and in case of formated floats, it is better to workl on already formated value. diff -r a8c81a080588 -r 99ce78ddd353 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Fri Feb 19 10:04:36 2021 +0100 +++ b/svghmi/gen_index_xhtml.xslt Sun Feb 21 21:38:44 2021 +0100 @@ -4452,16 +4452,12 @@ </xsl:if> <xsl:text> dispatch: function(value) { </xsl:text> - <xsl:if test="$have_edit"> - <xsl:text> this.last_val = value; -</xsl:text> - </xsl:if> - <xsl:if test="$have_value"> + <xsl:if test="$have_value or $have_edit"> <xsl:choose> <xsl:when test="count(arg) = 1"> <xsl:text> this.last_display = vsprintf("</xsl:text> <xsl:value-of select="arg[1]/@value"/> - <xsl:text>", value); + <xsl:text>", [value]); </xsl:text> </xsl:when> <xsl:otherwise> @@ -4469,6 +4465,8 @@ </xsl:text> </xsl:otherwise> </xsl:choose> + </xsl:if> + <xsl:if test="$have_value"> <xsl:text> this.request_animate(); </xsl:text> </xsl:if> @@ -4489,7 +4487,7 @@ <xsl:value-of select="path/@value"/> <xsl:text>", "</xsl:text> <xsl:value-of select="path/@type"/> - <xsl:text>", this, this.last_val); + <xsl:text>", this, this.last_display); </xsl:text> <xsl:if test="$have_value"> <xsl:text> this.value_elt.style.pointerEvents = "none"; diff -r a8c81a080588 -r 99ce78ddd353 svghmi/widget_input.ysl2 --- a/svghmi/widget_input.ysl2 Fri Feb 19 10:04:36 2021 +0100 +++ b/svghmi/widget_input.ysl2 Sun Feb 21 21:38:44 2021 +0100 @@ -41,18 +41,18 @@ | dispatch: function(value) { - if "$have_edit" - | this.last_val = value; - if "$have_value" { + if "$have_value or $have_edit" { choose{ when "count(arg) = 1" { - | this.last_display = vsprintf("«arg[1]/@value»", value); + | this.last_display = vsprintf("«arg[1]/@value»", [value]); } otherwise { | this.last_display = value; } } + } + if "$have_value" { | this.request_animate(); } | }, @@ -66,7 +66,7 @@ | init: function() { if "$have_edit" { - | this.edit_elt.onclick = () => edit_value("«path/@value»", "«path/@type»", this, this.last_val); + | this.edit_elt.onclick = () => edit_value("«path/@value»", "«path/@type»", this, this.last_display); if "$have_value" { | this.value_elt.style.pointerEvents = "none"; }