1 <!-- Copyleft 2004 - see COPYING for details [LGPL] -->
5 Authors: Charles Goodwin, David Crawshaw
7 For documentation, see ibex.theme.surface
12 var focus = null; // the current focus
14 // the focus list for this surface
15 var fvector = ibex..ibex.util.vector..newVector();
16 //var fvector = ibex..ibex.util.vector(ibex.box);
18 // read trap to access the focused child
19 surface.focus ++= function() { return focus; }
21 surface.setFocus ++= function(v) {
22 if (v and v.focusable and fvector.contains(v)) {
23 if (focus and focus != v) focus.focused = false;
26 else if (!v and focus) {
27 focus.focused = false;
33 // function to add a focus to the focus vector, optionally after w
34 surface.addFocus = function(v, w) {
35 // make sure we're not already in the focus list
38 if (w and fvector.contains(w))
39 return fvector.insert(v, w);
40 else return fvector.push(v);
43 // function to drop a focus from the focus vector for this surface
44 surface.dropFocus = function(v) {
45 if (fvector.contains(v)) {
46 if (focus == v) focus = v.nextfocus;
47 return fvector.remove(v);
52 // function to return the next-in-line for focus after v
53 surface.nextFocus ++= function(v) {
54 var nf = fvector.after(v);
55 while (!nf.focusable and nf != v) nf = fvector.after(nf);
59 // function to return the previous-in-line for focus after v
60 surface.prevFocus ++= function(v) {
61 var pf = fvector.after(v);
62 while (!pf.focusable and pf != v) pf = fvector.before(pf);
66 // private function to map events from this root ui:box onto the focused child
67 var passEvent = function(v) { if (focus) focus[trapname] = v; }
69 _KeyPressed ++= passEvent; // pass keypress events to focused child
70 _KeyReleased ++= passEvent; // pass keyrelease events to focused child