From 0cb456bbab73abfd9c08af101d1dfe71cf2d41d4 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Mon, 23 Jul 2012 08:38:39 -0400 Subject: Add more global mouse event hooks --- lib/js/urweb.js | 12 ++++++++++++ lib/ur/basis.urs | 3 +++ src/settings.sml | 9 +++++++++ tests/globalHandlers.ur | 6 ++++++ 4 files changed, 30 insertions(+) diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 1f003fc3..63aab9b5 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -504,6 +504,18 @@ function uw_onMousedown(f) { uw_handler("onmousedown", f); } +function uw_onMousemove(f) { + uw_handler("onmousemove", f); +} + +function uw_onMouseout(f) { + uw_handler("onmouseout", f); +} + +function uw_onMouseover(f) { + uw_handler("onmouseover", f); +} + function uw_onMouseup(f) { uw_handler("onmouseup", f); } diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs index cb5d16ea..101f8e63 100644 --- a/lib/ur/basis.urs +++ b/lib/ur/basis.urs @@ -981,6 +981,9 @@ val onKeydown : (keyEvent -> transaction unit) -> transaction unit val onKeypress : (keyEvent -> transaction unit) -> transaction unit val onKeyup : (keyEvent -> transaction unit) -> transaction unit val onMousedown : (mouseEvent -> transaction unit) -> transaction unit +val onMousemove : (mouseEvent -> transaction unit) -> transaction unit +val onMouseout : (mouseEvent -> transaction unit) -> transaction unit +val onMouseover : (mouseEvent -> transaction unit) -> transaction unit val onMouseup : (mouseEvent -> transaction unit) -> transaction unit (* Prevents default handling of current event *) diff --git a/src/settings.sml b/src/settings.sml index 9359337d..6712925f 100644 --- a/src/settings.sml +++ b/src/settings.sml @@ -174,6 +174,9 @@ val benignBase = basis ["get_cookie", "onKeypress", "onKeyup", "onMousedown", + "onMousemove", + "onMouseout", + "onMouseover", "onMouseup", "preventDefault", "stopPropagation", @@ -204,6 +207,9 @@ val clientBase = basis ["get_client_source", "onKeypress", "onKeyup", "onMousedown", + "onMousemove", + "onMouseout", + "onMouseover", "onMouseup", "preventDefault", "stopPropagation", @@ -320,6 +326,9 @@ val jsFuncsBase = basisM [("alert", "alert"), ("onKeypress", "uw_onKeypress"), ("onKeyup", "uw_onKeyup"), ("onMousedown", "uw_onMousedown"), + ("onMousemove", "uw_onMousemove"), + ("onMouseout", "uw_onMouseout"), + ("onMouseover", "uw_onMouseover"), ("onMouseup", "uw_onMouseup"), ("preventDefault", "uw_preventDefault"), ("stopPropagation", "uw_stopPropagation"), diff --git a/tests/globalHandlers.ur b/tests/globalHandlers.ur index 2b4fba7b..5ab46de8 100644 --- a/tests/globalHandlers.ur +++ b/tests/globalHandlers.ur @@ -2,3 +2,9 @@ fun main () : transaction page = return alert ("ScreenX = " ^ show ev.ScreenX ^ "\nShiftKey = " ^ show ev.ShiftKey)); onKeypress (fn ev => alert ("KeyCode = " ^ show ev.KeyCode ^ "\nShiftKey = " ^ show ev.ShiftKey))}/> + +fun busy () : transaction page = return + alert "OUT!"); + onMouseover (fn _ => alert "OVER!"); + onMousemove (fn _ => alert "MOVE!")}/> + -- cgit v1.2.3