changeset 1784:e6bc6bbd7a32

Update demo code for key/mouse handler change
author Adam Chlipala <adam@chlipala.net>
date Sat, 21 Jul 2012 10:12:35 -0400
parents 5bc4fbf9c0fe
children ffd7ed3bc0b7
files demo/alert.ur demo/batch.ur demo/batchFun.ur demo/chat.ur demo/increment.ur demo/listEdit.ur demo/more/dragList.ur demo/more/grid.ur demo/more/versioned1.ur demo/noisy.ur demo/react.ur
diffstat 11 files changed, 57 insertions(+), 57 deletions(-) [+]
line wrap: on
line diff
--- a/demo/alert.ur	Sat Jul 21 10:02:53 2012 -0400
+++ b/demo/alert.ur	Sat Jul 21 10:12:35 2012 -0400
@@ -1,3 +1,3 @@
 fun main () = return <xml><body>
-  <button value="Click me!" onclick={alert "You clicked me!"}/>
+  <button value="Click me!" onclick={fn _ => alert "You clicked me!"}/>
 </body></xml>
--- a/demo/batch.ur	Sat Jul 21 10:02:53 2012 -0400
+++ b/demo/batch.ur	Sat Jul 21 10:12:35 2012 -0400
@@ -25,7 +25,7 @@
                 Nil => <xml/>
               | Cons ((id, a), ls) => <xml>
                 <tr><td>{[id]}</td> <td>{[a]}</td> {if withDel then
-                                                        <xml><td><button value="Delete" onclick={rpc (del id)}/>
+                                                        <xml><td><button value="Delete" onclick={fn _ => rpc (del id)}/>
                                                         </td></xml>
                                                     else
                                                         <xml/>} </tr>
@@ -64,7 +64,7 @@
 
           {show True lss}
 
-          <button value="Update" onclick={ls <- rpc (allRows ()); set lss ls}/><br/>
+          <button value="Update" onclick={fn _ => ls <- rpc (allRows ()); set lss ls}/><br/>
           <br/>
 
           <h2>Batch new rows to add</h2>
@@ -72,11 +72,11 @@
           <table>
             <tr> <th>Id:</th> <td><ctextbox source={id}/></td> </tr>
             <tr> <th>A:</th> <td><ctextbox source={a}/></td> </tr>
-            <tr> <th/> <td><button value="Batch it" onclick={add ()}/></td> </tr>
+            <tr> <th/> <td><button value="Batch it" onclick={fn _ => add ()}/></td> </tr>
           </table>
 
           <h2>Already batched:</h2>
           {show False batched}
-          <button value="Execute" onclick={exec ()}/>
+          <button value="Execute" onclick={fn _ => exec ()}/>
         </body></xml>
     end
--- a/demo/batchFun.ur	Sat Jul 21 10:02:53 2012 -0400
+++ b/demo/batchFun.ur	Sat Jul 21 10:12:35 2012 -0400
@@ -75,7 +75,7 @@
                             <xml><td>{m.Show v}</td></xml>)
                         M.fl M.cols (r -- #Id)}
                       {if withDel then
-                           <xml><td><button value="Delete" onclick={rpc (del r.Id)}/></td></xml>
+                           <xml><td><button value="Delete" onclick={fn _ => rpc (del r.Id)}/></td></xml>
                        else
                            <xml/>}
                     </tr>
@@ -132,7 +132,7 @@
 
               {show True lss}
 
-              <button value="Update" onclick={ls <- rpc (allRows ()); set lss ls}/><br/>
+              <button value="Update" onclick={fn _ => ls <- rpc (allRows ()); set lss ls}/><br/>
               <br/>
 
               <h2>Batch new rows to add</h2>
@@ -143,12 +143,12 @@
                   (fn [nm :: Name] [p ::_] [rest ::_] [[nm] ~ rest] m s =>
                       <xml><tr> <th>{[m.Nam]}:</th> <td>{m.Widget s}</td> </tr></xml>)
                   M.fl M.cols inps}
-                <tr> <th/> <td><button value="Batch it" onclick={add ()}/></td> </tr>
+                <tr> <th/> <td><button value="Batch it" onclick={fn _ => add ()}/></td> </tr>
               </table>
 
               <h2>Already batched:</h2>
               {show False batched}
-              <button value="Execute" onclick={exec ()}/>
+              <button value="Execute" onclick={fn _ => exec ()}/>
             </body></xml>
         end
 
--- a/demo/chat.ur	Sat Jul 21 10:02:53 2012 -0400
+++ b/demo/chat.ur	Sat Jul 21 10:12:35 2012 -0400
@@ -40,7 +40,7 @@
         return <xml><body onload={onload ()}>
           <h1>{[r.T.Title]}</h1>
 
-          <button value="Send:" onclick={doSpeak ()}/> <ctextbox source={newLine}/>
+          <button value="Send:" onclick={fn _ => doSpeak ()}/> <ctextbox source={newLine}/>
 
           <h2>Messages</h2>
 
--- a/demo/increment.ur	Sat Jul 21 10:02:53 2012 -0400
+++ b/demo/increment.ur	Sat Jul 21 10:12:35 2012 -0400
@@ -6,5 +6,5 @@
     src <- source 0;
     return <xml><body>
       <dyn signal={n <- signal src; return <xml>{[n]}</xml>}/>
-      <button value="Update" onclick={n <- rpc (increment ()); set src n}/>
+      <button value="Update" onclick={fn _ => n <- rpc (increment ()); set src n}/>
     </body></xml>
--- a/demo/listEdit.ur	Sat Jul 21 10:02:53 2012 -0400
+++ b/demo/listEdit.ur	Sat Jul 21 10:12:35 2012 -0400
@@ -15,7 +15,7 @@
         Nil => return <xml/>
       | Cons {Data = ss, NewData = ss', Tail = rls} => return <xml>
         <dyn signal={showString ss}/>
-        <button value="Change to:" onclick={s <- get ss'; set ss s}/>
+        <button value="Change to:" onclick={fn _ => s <- get ss'; set ss s}/>
         <ctextbox source={ss'}/><br/>
         <dyn signal={show rls}/>
       </xml>
@@ -46,7 +46,7 @@
             end
     in
         return <xml><body>
-          <ctextbox source={data}/> <button value="Add" onclick={add ()}/><br/>
+          <ctextbox source={data}/> <button value="Add" onclick={fn _ => add ()}/><br/>
           <br/>
 
           <dyn signal={show head}/>
--- a/demo/more/dragList.ur	Sat Jul 21 10:02:53 2012 -0400
+++ b/demo/more/dragList.ur	Sat Jul 21 10:12:35 2012 -0400
@@ -5,16 +5,16 @@
       <h2>Great {[title]}</h2>
       <ul>
         {List.mapX (fn itemSource => <xml>
-          <li onmousedown={set draggingItem (Some itemSource)}
-              onmouseup={set draggingItem None}
-              onmouseover={di <- get draggingItem;
-                           case di of
-                               None => return ()
-                             | Some di => original <- get di;
-                               movedOver <- get itemSource;
-                               set di movedOver;
-                               set itemSource original;
-                               set draggingItem (Some itemSource)}>
+          <li onmousedown={fn _ => set draggingItem (Some itemSource)}
+              onmouseup={fn _ => set draggingItem None}
+              onmouseover={fn _ => di <- get draggingItem;
+                              case di of
+                                  None => return ()
+                                | Some di => original <- get di;
+                                  movedOver <- get itemSource;
+                                  set di movedOver;
+                                  set itemSource original;
+                                  set draggingItem (Some itemSource)}>
               <dyn signal={Monad.mp cdata (signal itemSource)}/>
          </li></xml>) itemSources}
       </ul>
--- a/demo/more/grid.ur	Sat Jul 21 10:02:53 2012 -0400
+++ b/demo/more/grid.ur	Sat Jul 21 10:12:35 2012 -0400
@@ -124,7 +124,7 @@
     fun render (grid : grid) = <xml>
       <table class={tabl}>
         <tr class={tr}>
-          <th/> <th/> <th><button value="No sort" onclick={set grid.Sort None}/></th>
+          <th/> <th/> <th><button value="No sort" onclick={fn _ => set grid.Sort None}/></th>
           {@mapX2 [fst3] [colMeta M.row] [tr]
             (fn [nm :: Name] [p :: (Type * Type * Type)] [rest :: {(Type * Type * Type)}] [[nm] ~ rest]
                              data (meta : colMeta M.row p) =>
@@ -132,7 +132,7 @@
                   {case (meta.Handlers data).Sort of
                        None => txt (meta.Handlers data).Header
                      | sort => <xml><button value={(meta.Handlers data).Header}
-                                                      onclick={set grid.Sort sort}/></xml>}
+                                            onclick={fn _ => set grid.Sort sort}/></xml>}
                 </th></xml>)
             M.folder grid.Cols M.cols}
         </tr>
@@ -197,16 +197,16 @@
                                 <td>
                                   <dyn signal={b <- signal ud;
                                                return (if b then
-                                                           <xml><button value="Save" onclick={save}/></xml>
+                                                           <xml><button value="Save" onclick={fn _ => save}/></xml>
                                                        else
-                                                           <xml><button value="Update" onclick={update}/></xml>)}/>
+                                                           <xml><button value="Update" onclick={fn _ => update}/></xml>)}/>
                                 </td>
 
                                 <td><dyn signal={b <- signal ud;
                                                  return (if b then
-                                                             <xml><button value="Cancel" onclick={cancel}/></xml>
+                                                             <xml><button value="Cancel" onclick={fn _ => cancel}/></xml>
                                                          else
-                                                             <xml><button value="Delete" onclick={delete}/></xml>)}/>
+                                                             <xml><button value="Delete" onclick={fn _ => delete}/></xml>)}/>
                                 </td>
 
                                 <dyn signal={cols <- signal colsS;
@@ -302,8 +302,8 @@
                                                                            else
                                                                                <xml>
                                                                                  <button value={show (n + 1)}
-                                                                                         onclick={set grid.Position
-                                                                                                      (n * plen)
+                                                                                         onclick={fn _ => set grid.Position
+                                                                                                              (n * plen)
                                                                                                  }/></xml>)}/>
                                                       {if (n + 1) * plen >= avail then <xml/> else <xml>|</xml>}
                                                       {pages (n + 1)}
@@ -313,9 +313,9 @@
                                         end)}/>
                </xml>}
           
-          <button value="New row" onclick={row <- rpc M.new;
-                                           addRow grid.Cols grid.Rows row}/>
-          <button value="Refresh" onclick={sync grid}/>
+          <button value="New row" onclick={fn _ => row <- rpc M.new;
+                                              addRow grid.Cols grid.Rows row}/>
+          <button value="Refresh" onclick={fn _ => sync grid}/>
     </xml>
 
     fun showSelection grid = grid.Selection
--- a/demo/more/versioned1.ur	Sat Jul 21 10:02:53 2012 -0400
+++ b/demo/more/versioned1.ur	Sat Jul 21 10:12:35 2012 -0400
@@ -43,17 +43,17 @@
                      {[kr.Key]}:
                      <ctextbox source={kr.Nam}/>
                      <ctextbox size={5} source={kr.ShoeSize}/>
-                     <button value="Latest" onclick={ro <- rpc (current {Id = kr.Key});
-                                                     case ro of
-                                                         None => alert "Can't get it!"
-                                                       | Some r =>
-                                                         set kr.Nam r.Nam;
-                                                         set kr.ShoeSize (show r.ShoeSize)}/>
-                     <button value="Update" onclick={name <- get kr.Nam;
-                                                     shoeSize <- get kr.ShoeSize;
-                                                     rpc (update {Id = kr.Key,
-                                                                  Nam = name,
-                                                                  ShoeSize = readError shoeSize})
+                     <button value="Latest" onclick={fn _ => ro <- rpc (current {Id = kr.Key});
+                                                        case ro of
+                                                            None => alert "Can't get it!"
+                                                          | Some r =>
+                                                            set kr.Nam r.Nam;
+                                                            set kr.ShoeSize (show r.ShoeSize)}/>
+                     <button value="Update" onclick={fn _ => name <- get kr.Nam;
+                                                        shoeSize <- get kr.ShoeSize;
+                                                        rpc (update {Id = kr.Key,
+                                                                     Nam = name,
+                                                                     ShoeSize = readError shoeSize})
                                                     }/>
                    </div></xml>) ks)}/>
 
@@ -63,15 +63,15 @@
         <tr><th>Id:</th> <td><ctextbox size={5} source={id}/></td></tr>
         <tr><th>Name:</th> <td><ctextbox source={name}/></td></tr>
         <tr><th>Shoe size:</th> <td><ctextbox size={5} source={shoeSize}/></td></tr>
-        <tr><th><button value="Add" onclick={id <- get id;
-                                             name <- get name;
-                                             shoeSize <- get shoeSize;
-                                             rpc (insert {Id = readError id, Nam = name,
-                                                          ShoeSize = readError shoeSize});
+        <tr><th><button value="Add" onclick={fn _ => id <- get id;
+                                                name <- get name;
+                                                shoeSize <- get shoeSize;
+                                                rpc (insert {Id = readError id, Nam = name,
+                                                             ShoeSize = readError shoeSize});
 
-                                             cur <- get ks;
-                                             kr <- expandKey (readError id);
-                                             set ks (kr :: cur)}/></th></tr>
+                                                cur <- get ks;
+                                                kr <- expandKey (readError id);
+                                                set ks (kr :: cur)}/></th></tr>
       </table>
 
       <h2>Archive</h2>
--- a/demo/noisy.ur	Sat Jul 21 10:02:53 2012 -0400
+++ b/demo/noisy.ur	Sat Jul 21 10:12:35 2012 -0400
@@ -32,12 +32,12 @@
     idDel <- source "";
 
     return <xml><body>
-      <button value="Check values of 1, 2, and 3" onclick={check (Cons (1, Cons (2, Cons (3, Nil))))}/><br/>
+      <button value="Check values of 1, 2, and 3" onclick={fn _ => check (Cons (1, Cons (2, Cons (3, Nil))))}/><br/>
       <br/>
-      <button value="Add" onclick={id <- get idAdd; a <- get aAdd; rpc (add (readError id) a)}/>
+      <button value="Add" onclick={fn _ => id <- get idAdd; a <- get aAdd; rpc (add (readError id) a)}/>
       <ctextbox source={idAdd}/>
       <ctextbox source={aAdd}/><br/>
       <br/>
-      <button value="Delete" onclick={id <- get idDel; rpc (del (readError id))}/>
+      <button value="Delete" onclick={fn _ => id <- get idDel; rpc (del (readError id))}/>
       <ctextbox source={idDel}/>
     </body></xml>
--- a/demo/react.ur	Sat Jul 21 10:02:53 2012 -0400
+++ b/demo/react.ur	Sat Jul 21 10:12:35 2012 -0400
@@ -1,6 +1,6 @@
 fun main () =
   s <- source "You didn't click it yet.";
   return <xml><body>
-    <button value="Click me!" onclick={set s "Now you clicked it."}/><br/>
+    <button value="Click me!" onclick={fn _ => set s "Now you clicked it."}/><br/>
     <dyn signal={v <- signal s; return <xml>{[v]}</xml>}/>
   </body></xml>