Mercurial > urweb
comparison demo/more/dragList.ur @ 916:b873feb3eb52
dragList almost kinda works
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 08 Sep 2009 10:18:19 -0400 |
parents | |
children | 321a2d6feb40 |
comparison
equal
deleted
inserted
replaced
915:5e8b6fa5b48f | 916:b873feb3eb52 |
---|---|
1 fun draggableList title items = | |
2 itemSources <- List.mapM source items; | |
3 draggingItem <- source None; | |
4 return <xml> | |
5 <h2>Great {[title]}</h2> | |
6 <ul> | |
7 {List.mapX (fn itemSource => <xml> | |
8 <li onmousedown={set draggingItem (Some itemSource)} | |
9 onmouseup={set draggingItem None} | |
10 onmouseover={di <- get draggingItem; | |
11 case di of | |
12 None => return () | |
13 | Some di => item1 <- get di; | |
14 item2 <- get itemSource; | |
15 set di item2; | |
16 set itemSource item1}> | |
17 <dyn signal={s <- signal itemSource; return <xml>{[s]}</xml>}/> | |
18 </li></xml>) itemSources} | |
19 </ul> | |
20 </xml> | |
21 | |
22 fun main () = | |
23 bears <- draggableList "Bears" ("Pooh" :: "Paddington" :: "Rupert" :: "Edward" :: []); | |
24 beers <- draggableList "Beers" ("Budvar" :: "Delirium Tremens" :: "Deuchars" :: []); | |
25 boars <- draggableList "Boars" ("Sus scrofa scrofa" | |
26 :: "Sus scrofa ussuricus" | |
27 :: "Sus scrofa cristatus" | |
28 :: "Sus scrofa taiwanus" :: []); | |
29 return <xml><body> | |
30 {bears} | |
31 {beers} | |
32 {boars} | |
33 </body></xml> |