1 <!-- Copyright 2004 - see COPYING for details [LGPL] -->
5 See ibex.theme.focusable for more details
7 <author>Charles Goodwin</author>
8 <author>David Crawshaw</author>
13 thisbox.enabled; // whether a focusable is enabled
14 thisbox.focusable; // whether a focusable may be focused
15 thisbox.focused; // whether a focusable is focused
16 thisbox.nextfocus; // read for the focus after thisbox on the surface
17 thisbox.prevfocus; // read for the focus before thisbox on the surface
19 // private function to assign to traps
20 var checkfocus = function(v) { if (!v and focused) focused = false; }
22 enabled ++= checkfocus; // disabling prevents focus
23 focusable ++= checkfocus; // making unfocusable prevents focus
25 // read trap to return focusable state
26 focusable ++= function() { return enabled and cascade; }
28 // write trap to set focused state
29 focused ++= function(v) {
30 if (v and surface and focusable) {
32 surface.focus.focused = false;
34 surface.focus = thisbox;
36 else if (!v and surface and surface.focus == thisbox)
41 // read trap to return the focus after thisbox on the surface
42 nextfocus ++= function() { return surface.nextFocus(thisbox); }
44 // read trap to return the focus before thisbox on the surface
45 prevfocus ++= function() { return surface.prevFocus(thisbox); }
47 // write trap to handle surface change
48 surface ++= function(v) {
49 // drop from current surface if there is one
50 if (cascade) cascade.dropFocus(thisbox);
56 // write trap to focus on Press1
57 Press1 ++= function(v) { if (!focused and focusable) focused = true; }