# HG changeset patch # User Edouard Tisserant # Date 1586877192 -7200 # Node ID 23c35f3ba111c186a7744830483f2d3810293d6a # Parent 90f9d9782632a93386e1e3dc32236eaa731c8a21 SVGHMI: HMI:DropDown now catches all clicks when open diff -r 90f9d9782632 -r 23c35f3ba111 svghmi/widget_dropdown.ysl2 --- a/svghmi/widget_dropdown.ysl2 Tue Apr 14 12:07:08 2020 +0200 +++ b/svghmi/widget_dropdown.ysl2 Tue Apr 14 17:13:12 2020 +0200 @@ -20,6 +20,7 @@ this.menu_offset = 0; this.lift = 0; this.opened = false; + this.bound_inhibit_click_elsewhere = this.inhibit_click_elsewhere.bind(this); }, on_selection_click: function(selection) { console.log("selected "+selection); @@ -72,10 +73,17 @@ } return count; }, + 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(); this.reset_box(); this.element.appendChild(this.button_elt); + document.removeEventListener("click", this.bound_inhibit_click_elsewhere, true); this.opened = false; }, set_complete_text: function(){ @@ -138,7 +146,8 @@ } this.adjust_box_to_text(); this.element.removeChild(this.button_elt); - /* TODO disable interaction with background */ + // disable interaction with background + document.addEventListener("click", this.bound_inhibit_click_elsewhere, true); this.opened = true; }, reset_text: function(){