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;
94 this.setFocus(this, e);
95 if (e && e.instanceOfInputContainer)
97 e.focusedChild = NULL;
98 e._changeFocusXY(e, globalToBox(pos, e.Container_origin, e.Container_size));
101 return true; // have focus
104 float InputContainer_mouseDrag(entity me, vector pos)
106 if (SUPER(InputContainer).mouseDrag(me, pos)) return 1;
107 if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;
110 float InputContainer_mouseMove(entity me, vector pos)
112 if (me.mouseFocusedChild != me.focusedChild) // if the keyboard moved the focus away
113 me.mouseFocusedChild = NULL; // force focusing
114 if (me._changeFocusXY(me, pos))
115 if (SUPER(InputContainer).mouseMove(me, pos)) return 1;
116 if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;
119 METHOD(InputContainer, mousePress, bool(InputContainer this, vector pos))
121 this.mouseFocusedChild = NULL; // force focusing
122 if (this._changeFocusXY(this, pos))
123 if (SUPER(InputContainer).mousePress(this, pos)) return true;
124 if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return true;
127 float InputContainer_mouseRelease(entity me, vector pos)
129 SUPER(InputContainer).mouseRelease(me, pos); // return value?
130 if (me.focused) // am I still eligible for this? (UGLY HACK, but a mouse event could have changed focus away)
131 if (me._changeFocusXY(me, pos)) return 1;
132 if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;