diff options
author | 2011-09-11 14:14:49 -0400 | |
---|---|---|
committer | 2011-09-11 14:14:49 -0400 | |
commit | 027e8d90fdd3f74698ed40974294fd053a70cd20 (patch) | |
tree | 83bc389429c007e44e18c3d6eba6077a7148bf77 /lib | |
parent | b6ad8fe5b4adacea14831171734f954969a72e23 (diff) |
New Basis functions: preventDefault and stopPropagation (code contributed by Vladimir Shabanov)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/js/urweb.js | 21 | ||||
-rw-r--r-- | lib/ur/basis.urs | 5 |
2 files changed, 22 insertions, 4 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 7f636ef9..d7149eba 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -215,9 +215,9 @@ function kc() { function uw_handler(name, f) { var old = document[name]; if (old == undefined) - document[name] = function() { execF(f); return false; }; + document[name] = function(event) { uw_event = event; execF(f); }; else - document[name] = function() { old(); execF(f); return false; }; + document[name] = function(event) { uw_event = event; old(); execF(f); }; } function uw_onClick(f) { @@ -239,9 +239,9 @@ function uw_onMouseup(f) { function uw_keyHandler(name, f) { var old = document[name]; if (old == undefined) - document[name] = function(event) { uw_event = event; execF(execF(f, kc())); return false; }; + document[name] = function(event) { uw_event = event; execF(execF(f, kc())); }; else - document[name] = function(event) { uw_event = event; old(); execF(execF(f, kc())); return false; }; + document[name] = function(event) { uw_event = event; old(); execF(execF(f, kc())); }; } function uw_onKeydown(f) { @@ -256,6 +256,19 @@ function uw_onKeyup(f) { uw_keyHandler("onkeyup", f); } +// Cancelling of further event processing + +function uw_preventDefault() { + var e = window.event ? window.event : uw_event; + e.returnValue = false; + if (e.preventDefault) e.preventDefault(); +} + +function uw_stopPropagation() { + var e = window.event ? window.event : uw_event; + e.cancelBubble = true; + if (e.stopPropagation) e.stopPropagation(); +} // Embedding closures in XML strings diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs index 6657034f..03b4d4d1 100644 --- a/lib/ur/basis.urs +++ b/lib/ur/basis.urs @@ -870,6 +870,11 @@ val onKeyup : (int -> transaction unit) -> transaction unit val onMousedown : transaction unit -> transaction unit val onMouseup : transaction unit -> transaction unit +(* Prevents default handling of current event *) +val preventDefault : transaction unit +(* Stops propagation of current event *) +val stopPropagation : transaction unit + val show_xml : ctx ::: {Unit} -> use ::: {Type} -> bind ::: {Type} -> show (xml ctx use bind) |