# HG changeset patch # User Edouard Tisserant # Date 1586877455 -7200 # Node ID 41edcb8e0a0144961eb80ea24f95e62619309e9f # Parent 9179cbc6fc49690fe65d6d0f9e6f339a5cb8685e SVGHMI: Connect HMI:DropDown to value in HMI Tree, in svghmi test as well. diff -r 9179cbc6fc49 -r 41edcb8e0a01 svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Tue Apr 14 17:16:25 2020 +0200 +++ b/svghmi/gen_index_xhtml.xslt Tue Apr 14 17:17:35 2020 +0200 @@ -859,6 +859,8 @@ this.opened = false; + this.bound_inhibit_click_elsewhere = this.inhibit_click_elsewhere.bind(this); + }, on_selection_click: function(selection) { @@ -867,7 +869,11 @@ this.close(); - this.set_selection(selection); + let orig = this.indexes[0]; + + let idx = this.offset ? orig - this.offset : orig; + + apply_hmi_value(idx, selection); }, @@ -963,6 +969,18 @@ }, + inhibit_click_elsewhere: function(e) { + + console.log("inhibit", e); + + console.log(e.target.parentNode, this.text_elt); + + if(e.target.parentNode !== this.text_elt) + + e.stopPropagation(); + + }, + close: function(){ this.reset_text(); @@ -971,6 +989,10 @@ this.element.appendChild(this.button_elt); + this.apply_cache(); + + document.removeEventListener("click", this.bound_inhibit_click_elsewhere, true); + this.opened = false; }, @@ -1103,7 +1125,11 @@ this.element.removeChild(this.button_elt); - /* TODO disable interaction with background */ + this.element.parentNode.appendChild(this.element.parentNode.removeChild(this.element)); + + // disable interaction with background + + document.addEventListener("click", this.bound_inhibit_click_elsewhere, true); this.opened = true; @@ -1327,7 +1353,11 @@ on_op_click: function(opstr) { - let new_val = change_hmi_value(this.indexes[0], opstr); + let orig = this.indexes[0]; + + let idx = this.offset ? orig - this.offset : orig; + + let new_val = change_hmi_value(idx, opstr); }, @@ -1343,7 +1373,11 @@ edit_callback: function(new_val) { - apply_hmi_value(this.indexes[0], new_val); + let orig = this.indexes[0]; + + let idx = this.offset ? orig - this.offset : orig; + + apply_hmi_value(idx, new_val); }, diff -r 9179cbc6fc49 -r 41edcb8e0a01 svghmi/widget_dropdown.ysl2 --- a/svghmi/widget_dropdown.ysl2 Tue Apr 14 17:16:25 2020 +0200 +++ b/svghmi/widget_dropdown.ysl2 Tue Apr 14 17:17:35 2020 +0200 @@ -25,7 +25,9 @@ on_selection_click: function(selection) { console.log("selected "+selection); this.close(); - this.set_selection(selection); + let orig = this.indexes[0]; + let idx = this.offset ? orig - this.offset : orig; + apply_hmi_value(idx, selection); }, on_button_click: function() { this.open(); @@ -83,6 +85,7 @@ this.reset_text(); this.reset_box(); this.element.appendChild(this.button_elt); + this.apply_cache(); document.removeEventListener("click", this.bound_inhibit_click_elsewhere, true); this.opened = false; }, diff -r 9179cbc6fc49 -r 41edcb8e0a01 tests/svghmi/plc.xml --- a/tests/svghmi/plc.xml Tue Apr 14 17:16:25 2020 +0200 +++ b/tests/svghmi/plc.xml Tue Apr 14 17:17:35 2020 +0200 @@ -1,7 +1,7 @@ - + @@ -25,6 +25,11 @@ + + + + + diff -r 9179cbc6fc49 -r 41edcb8e0a01 tests/svghmi/svghmi_0@svghmi/svghmi.svg --- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg Tue Apr 14 17:16:25 2020 +0200 +++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg Tue Apr 14 17:17:35 2020 +0200 @@ -124,16 +124,16 @@ inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:document-units="px" - inkscape:current-layer="g14237" + inkscape:current-layer="hmi0" showgrid="false" units="px" inkscape:zoom="0.35355339" inkscape:cx="-418.67433" inkscape:cy="-1206.7258" - inkscape:window-width="2112" - inkscape:window-height="1367" - inkscape:window-x="2960" - inkscape:window-y="54" + inkscape:window-width="1920" + inkscape:window-height="1080" + inkscape:window-x="3815" + inkscape:window-y="968" inkscape:window-maximized="0" showguides="true" inkscape:guide-bbox="true" /> @@ -2492,7 +2492,7 @@ + + 8888 + + + + +