resolve darcs stupidity
[org.ibex.core.git] / src / org / ibex / builtin / button.ibex
1 <!-- Copyright 2002 Adam Megacz, see the COPYING file for licensing [LGPL] -->
2 <ibex>
3
4     <redirect target="self"/>
5     <preapply name="org.ibex.builtin.bevel"/>
6     <template hot="false">
7
8         var owned = false;
9
10         _holdfrequency = function() { }
11
12         // FIXME: I don't know why I can't use an attribute for this; causes infinite loops
13         holdfrequency = 250;
14
15         __Press1 = function(message) {
16             owned = true;
17             press = true;
18
19             ibex.thread = function() {
20                 ibex.sleep(holdfrequency);
21                 while (owned) {
22                     if (ibex.button == 1 and mouseinside) hold = true;
23                     ibex.sleep(holdfrequency);
24                 }
25             }
26             root._Release1 = function() {
27                 if (mouseinside and owned) click = true;
28                 owned = false;
29                 root.__Release1 = null;
30                 release = true;
31             }
32         }
33
34         var owned = false;
35
36         _style = function(s) { arguments.cascade(s); sync_(); }
37
38         _Enter = function() { sync_(); }
39         _Leave = function() { sync_(); }
40         _press = function() { owned = true; sync_(); }
41         _release = function() { owned = false; sync_(); }
42
43         var sync_ = function() {
44             if (mouseinside and owned) depth = "flat";
45             else if (mouseinside) depth = "up";
46             else depth = "up";
47         }
48
49         sync_();
50
51     </template>
52
53 </ibex>