reorganized file layout (part 1: moves and renames)
[org.ibex.core.git] / src / org / ibex / core / builtin / button.ibex
diff --git a/src/org/ibex/core/builtin/button.ibex b/src/org/ibex/core/builtin/button.ibex
new file mode 100644 (file)
index 0000000..45bad31
--- /dev/null
@@ -0,0 +1,53 @@
+<!-- Copyright 2002 Adam Megacz, see the COPYING file for licensing [LGPL] -->
+<ibex>
+
+    <redirect target="self"/>
+    <preapply name="org.ibex.builtin.bevel"/>
+    <template hot="false">
+
+        var owned = false;
+
+        _holdfrequency = function() { }
+
+        // FIXME: I don't know why I can't use an attribute for this; causes infinite loops
+        holdfrequency = 250;
+
+        __Press1 = function(message) {
+            owned = true;
+            press = true;
+
+            ibex.thread = function() {
+                ibex.sleep(holdfrequency);
+                while (owned) {
+                    if (ibex.button == 1 and mouseinside) hold = true;
+                    ibex.sleep(holdfrequency);
+                }
+            }
+            root._Release1 = function() {
+                if (mouseinside and owned) click = true;
+                owned = false;
+                root.__Release1 = null;
+                release = true;
+            }
+        }
+
+        var owned = false;
+
+        _style = function(s) { arguments.cascade(s); sync_(); }
+
+        _Enter = function() { sync_(); }
+        _Leave = function() { sync_(); }
+        _press = function() { owned = true; sync_(); }
+        _release = function() { owned = false; sync_(); }
+
+        var sync_ = function() {
+            if (mouseinside and owned) depth = "flat";
+            else if (mouseinside) depth = "up";
+            else depth = "up";
+        }
+
+        sync_();
+
+    </template>
+
+</ibex>