1 <!-- Copyleft 2004 - see COPYING for details [LGPL] -->
5 See ibex.theme.clickable for details
8 <ibex.lib.repeatable />
11 // template properties
12 thisbox.enabled; // self explanatory
13 thisbox.repeats; // if a repeating action is desired
16 thisbox.action; // action trigger
19 thisbox.primed; // track activation irrespective of mouse.inside
21 // physical state triggers
22 thisbox.active; // active state (mouse.inside and primed)
23 thisbox.hover; // hover state (mouse.inside and !primed)
24 thisbox.normal; // normal state (!mouse.inside)
26 enabled ++= function(v) {
28 // deprime us when disabled
29 if (!v) { primed = false; normal = true; }
32 focused ++= function(v) {
34 // unprime if defocused
35 if (!v and primed) primed = false;
38 primed ++= function(v) {
40 // determine physical state and activate trigger
41 v ? active = true : (mouse.inside ? hover = true : normal = true);
42 // set repeat state if necessary
43 if (repeats) repeat = v;
45 // do nothing when not enabled
49 KeyPressed ++= function(v) {
50 if (v == "enter" or v == " ") primed = true;
51 else if (v == "escape") primed = false;
54 KeyReleased ++= function(v) {
55 if (v == "enter" or v == " ")
56 if (primed and enabled)
57 { action = true; primed = false; }
60 Enter ++= function(v) {
64 if (repeats) repeat = true;
70 Leave ++= function(v) {
73 if (repeats) repeat = false;
77 Press1 ++= function(v) {
81 surface.Release1 ++= function(v) {
85 if (mouse.inside) repeats ? repeat = false : action = true;
86 primed = false; // important: must occur _after_ action
90 surface.Release1 --= callee;
95 // initialise as normal state
96 // FIXME: redo this using better method (?)
97 SizeChange ++= function(v) {
99 SizeChange --= callee;