diff options
author | Adam Chlipala <adam@chlipala.net> | 2011-07-15 10:02:54 -0400 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2011-07-15 10:02:54 -0400 |
commit | ee5fb9b5b953cc21f94b5905316610ce84860302 (patch) | |
tree | 647ce68734dfce10572c974b4454cb4be41c5f40 | |
parent | da1f8066caeac8c68de52d36da831762eae97ccd (diff) |
Fixes for detecting pastes and autocompletes for dynamic textboxes
-rw-r--r-- | lib/js/urweb.js | 14 | ||||
-rw-r--r-- | tests/autocomp.ur | 11 |
2 files changed, 19 insertions, 6 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 272ba32b..76ad76fa 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -277,11 +277,13 @@ function sc(v) { return {data : v, dyns : null}; } function sv(s, v) { - s.data = v; + if (s.data != v) { + s.data = v; - for (var ls = s.dyns; ls; ls = ls.next) - if (!ls.dead) - populate(ls.data); + for (var ls = s.dyns; ls; ls = ls.next) + if (!ls.dead) + populate(ls.data); + } } function sg(s) { return s.data; @@ -491,7 +493,7 @@ function inp(s, name) { var x = input(document.createElement("input"), s, function(x) { return function(v) { if (x.value != v) x.value = v; }; }, null, name); x.value = s.data; - x.onkeyup = function() { sv(s, x.value) }; + x.onkeyup = x.oninput = x.onchange = x.onpropertychange = function() { sv(s, x.value) }; return x; } @@ -545,7 +547,7 @@ function tbx(s) { var x = input(document.createElement("textarea"), s, function(x) { return function(v) { if (x.innerHTML != v) x.innerHTML = v; }; }); x.innerHTML = s.data; - x.onkeyup = function() { sv(s, x.value) }; + x.onkeyup = x.oninput = x.onchange = x.onpropertychange = function() { sv(s, x.value) }; return x; } diff --git a/tests/autocomp.ur b/tests/autocomp.ur new file mode 100644 index 00000000..d4e6a287 --- /dev/null +++ b/tests/autocomp.ur @@ -0,0 +1,11 @@ +fun main () : transaction page = + a <- source ""; + b <- source ""; + return <xml><body> + <form> + <textbox{#A} source={a}/> + <button onclick={x <- get a; set b x}/> + <dyn signal={v <- signal a; return <xml>{[v]}</xml>}/> + / <dyn signal={v <- signal b; return <xml>{[v]}</xml>}/> + </form> + </body></xml> |