--- 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(){