1 #include "inputcontainer.qh"
3 void InputContainer_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
5 SUPER(InputContainer).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
7 if(me.parent.instanceOfInputContainer)
14 void InputContainer_focusLeave(entity me)
16 SUPER(InputContainer).focusLeave(me);
17 me.mouseFocusedChild = NULL;
20 float InputContainer_keyDown(entity me, float scan, float ascii, float shift)
23 if (SUPER(InputContainer).keyDown(me, scan, ascii, shift))
30 me.setFocus(me, NULL);
42 for (ff = f.prevSibling; ff; ff = ff.prevSibling)
44 if (!ff.focusable) continue;
49 if (!f || me.isTabRoot)
51 for (ff = me.lastChild; ff; ff = ff.prevSibling)
53 if (!ff.focusable) continue;
57 return 0; // AIIIIEEEEE!
64 for (ff = f.nextSibling; ff; ff = ff.nextSibling)
66 if (!ff.focusable) continue;
71 if (!f || me.isTabRoot)
73 for (ff = me.firstChild; ff; ff = ff.nextSibling)
75 if (!ff.focusable) continue;
79 return 0; // AIIIIEEEEE!
86 bool InputContainer__changeFocusXY(entity this, vector pos)
88 entity e = this.itemFromPoint(this, pos);
89 if (e && !e.focusable) e = NULL;
90 entity prev = this.mouseFocusedChild;
91 this.mouseFocusedChild = e;
92 if (!e) return false; // keep focus when hovering over non-focusable elements
95 this.setFocus(this, e);
96 if (e.instanceOfInputContainer)
98 e.focusedChild = NULL;
99 e._changeFocusXY(e, globalToBox(pos, e.Container_origin, e.Container_size));
102 return true; // have focus
105 float InputContainer_mouseDrag(entity me, vector pos)
107 if (SUPER(InputContainer).mouseDrag(me, pos)) return 1;
108 if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;
111 float InputContainer_mouseMove(entity me, vector pos)
113 if (me.mouseFocusedChild != me.focusedChild) // if the keyboard moved the focus away
114 me.mouseFocusedChild = NULL; // force focusing
115 if (me._changeFocusXY(me, pos))
116 if (SUPER(InputContainer).mouseMove(me, pos)) return 1;
117 if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;
120 float InputContainer_mousePress(entity me, vector pos)
122 me.mouseFocusedChild = NULL; // force focusing
123 if (me._changeFocusXY(me, pos))
124 if (SUPER(InputContainer).mousePress(me, pos)) return 1;
125 if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;
128 float InputContainer_mouseRelease(entity me, vector pos)
130 SUPER(InputContainer).mouseRelease(me, pos); // return value?
131 if (me.focused) // am I still eligible for this? (UGLY HACK, but a mouse event could have changed focus away)
132 if (me._changeFocusXY(me, pos)) return 1;
133 if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;