# HG changeset patch
# User Edouard Tisserant
# Date 1598515175 -7200
# Node ID ed43facc7137629fe79e2082fd527784860f8ed6
# Parent de4503de2f8c6997e7ce8326b0e77667d740e943
SVGHMI: Fix keypad : non-number input was always considered invalid because of missing type checking.
diff -r de4503de2f8c -r ed43facc7137 svghmi/gen_index_xhtml.xslt
--- a/svghmi/gen_index_xhtml.xslt Wed Aug 26 14:27:54 2020 +0200
+++ b/svghmi/gen_index_xhtml.xslt Thu Aug 27 09:59:35 2020 +0200
@@ -1510,8 +1510,6 @@
if (this.active_style && this.inactive_style) {
- console.log("pressedi...")
-
this.active_elt.setAttribute("style", this.active_style);
this.inactive_elt.setAttribute("style", "display:none");
@@ -1520,8 +1518,6 @@
this.apply_hmi_value(0, 1);
- console.log("pressed")
-
// TODO inhibit all mouse/touch events except mouse up (in other word grab cursor)
}
@@ -1532,8 +1528,6 @@
if (this.active_style && this.inactive_style) {
- console.log("unpressedi...")
-
this.active_elt.setAttribute("style", "display:none");
this.inactive_elt.setAttribute("style", this.inactive_style);
@@ -1542,8 +1536,6 @@
this.apply_hmi_value(0, 0);
- console.log("unpressed")
-
// TODO release inhibited events
}
@@ -3403,8 +3395,6 @@
.then(res => res.json())
- .then(function(res){console.log(res);return res;})
-
.then(this.spread_json_data.bind(this));
@@ -4115,13 +4105,15 @@
let coercedval = (typeof this.initial) == "number" ? Number(this.editstr) : this.editstr;
- if(isNaN(coercedval)){
+ if(typeof coercedval == 'number' && isNaN(coercedval)){
+
+ // revert to initial so it explicitely shows input was ignored
this.editstr = String(this.initial);
this.update();
- } else { // revert to initial so it explicitely shows input was ignored
+ } else {
let callback_obj = this.result_callback_obj;
diff -r de4503de2f8c -r ed43facc7137 svghmi/widget_keypad.ysl2
--- a/svghmi/widget_keypad.ysl2 Wed Aug 26 14:27:54 2020 +0200
+++ b/svghmi/widget_keypad.ysl2 Thu Aug 27 09:59:35 2020 +0200
@@ -89,10 +89,11 @@
on_Enter_click() {
let coercedval = (typeof this.initial) == "number" ? Number(this.editstr) : this.editstr;
- if(isNaN(coercedval)){
+ if(typeof coercedval == 'number' && isNaN(coercedval)){
+ // revert to initial so it explicitely shows input was ignored
this.editstr = String(this.initial);
this.update();
- } else { // revert to initial so it explicitely shows input was ignored
+ } else {
let callback_obj = this.result_callback_obj;
end_modal.call(this);
callback_obj.edit_callback(coercedval);