Mercurial > urweb
changeset 2130:e8863d9f8c59
New mouse events oncontextmenu, onmouseenter, and onmouseleave.
author | Ziv Scully <ziv@mit.edu> |
---|---|
date | Tue, 07 Apr 2015 14:18:53 -0400 |
parents | e0843b2a636d |
children | 88a8a656003f 54884b28b6c6 |
files | lib/js/urweb.js lib/ur/basis.urs src/settings.sml tests/docevents.ur |
diffstat | 4 files changed, 30 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/js/urweb.js Sun Mar 08 11:12:28 2015 -0400 +++ b/lib/js/urweb.js Tue Apr 07 14:18:53 2015 -0400 @@ -537,6 +537,10 @@ uw_handler("onclick", f); } +function uw_onContextmenu(f) { + uw_handler("oncontextmenu", f); +} + function uw_onDblclick(f) { uw_handler("ondblclick", f); } @@ -545,6 +549,14 @@ uw_handler("onmousedown", f); } +function uw_onMouseenter(f) { + uw_handler("onmouseenter", f); +} + +function uw_onMouseleave(f) { + uw_handler("onmouseleave", f); +} + function uw_onMousemove(f) { uw_handler("onmousemove", f); }
--- a/lib/ur/basis.urs Sun Mar 08 11:12:28 2015 -0400 +++ b/lib/ur/basis.urs Tue Apr 07 14:18:53 2015 -0400 @@ -833,7 +833,7 @@ Button : mouseButton } con mouseEvents = map (fn _ :: Unit => mouseEvent -> transaction unit) - [Onclick, Ondblclick, Onmousedown, Onmousemove, Onmouseout, Onmouseover, Onmouseup] + [Onclick, Oncontextmenu, Ondblclick, Onmousedown, Onmouseenter, Onmouseleave, Onmousemove, Onmouseout, Onmouseover, Onmouseup] type keyEvent = { KeyCode : int, CtrlKey : bool, ShiftKey : bool, AltKey : bool, MetaKey : bool } @@ -1120,10 +1120,13 @@ (* More standard document-level JavaScript handlers *) val onClick : (mouseEvent -> transaction unit) -> transaction unit val onDblclick : (mouseEvent -> transaction unit) -> transaction unit +val onContextmenu : (mouseEvent -> transaction unit) -> transaction unit 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 onMouseenter : (mouseEvent -> transaction unit) -> transaction unit +val onMouseleave : (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
--- a/src/settings.sml Sun Mar 08 11:12:28 2015 -0400 +++ b/src/settings.sml Tue Apr 07 14:18:53 2015 -0400 @@ -176,10 +176,13 @@ "spawn", "onClick", "onDblclick", + "onContextmenu", "onKeydown", "onKeypress", "onKeyup", "onMousedown", + "onMouseenter", + "onMouseleave", "onMousemove", "onMouseout", "onMouseover", @@ -212,11 +215,14 @@ "mouseEvent", "keyEvent", "onClick", + "onContextmenu", "onDblclick", "onKeydown", "onKeypress", "onKeyup", "onMousedown", + "onMouseenter", + "onMouseleave", "onMousemove", "onMouseout", "onMouseover", @@ -349,11 +355,14 @@ ("onClick", "uw_onClick"), + ("onContextmenu", "uw_onContextmenu"), ("onDblclick", "uw_onDblclick"), ("onKeydown", "uw_onKeydown"), ("onKeypress", "uw_onKeypress"), ("onKeyup", "uw_onKeyup"), ("onMousedown", "uw_onMousedown"), + ("onMouseenter", "uw_onMouseenter"), + ("onMouseleave", "uw_onMouseleave"), ("onMousemove", "uw_onMousemove"), ("onMouseout", "uw_onMouseout"), ("onMouseover", "uw_onMouseover"), @@ -764,7 +773,7 @@ fun mangleSql s = if #name (currentDbms ()) = "mysql" then if !mangle then - "uw_" ^ allLower s + "uw_" ^ allLower s else allLower s else
--- a/tests/docevents.ur Sun Mar 08 11:12:28 2015 -0400 +++ b/tests/docevents.ur Tue Apr 07 14:18:53 2015 -0400 @@ -1,6 +1,7 @@ fun main () : transaction page = return <xml> - <body onload={onDblclick (alert "Double click"); - onKeypress (fn k => alert ("Keypress: " ^ show k))}> + <body onload={onDblclick (fn _ => alert "Double click"); + onContextmenu (fn _ => alert "Context menu"); + onKeypress (fn k => alert ("Keypress: " ^ show k.KeyCode))}> Nothing here. - </body> + </body> </xml>