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)) return 1;
29 me.setFocus(me, NULL);
41 for (ff = f.prevSibling; ff; ff = ff.prevSibling)
43 if (!ff.focusable) continue;
48 if (!f || me.isTabRoot)
50 for (ff = me.lastChild; ff; ff = ff.prevSibling)
52 if (!ff.focusable) continue;
56 return 0; // AIIIIEEEEE!
63 for (ff = f.nextSibling; ff; ff = ff.nextSibling)
65 if (!ff.focusable) continue;
70 if (!f || me.isTabRoot)
72 for (ff = me.firstChild; ff; ff = ff.nextSibling)
74 if (!ff.focusable) continue;
78 return 0; // AIIIIEEEEE!
85 bool InputContainer__changeFocusXY(entity this, vector pos)
87 entity e = this.itemFromPoint(this, pos);
88 if (e && !e.focusable) e = NULL;
89 entity prev = this.mouseFocusedChild;
90 this.mouseFocusedChild = e;
91 if (!e) return false; // keep focus when hovering over non-focusable elements
94 this.setFocus(this, e);
95 if (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 float InputContainer_mousePress(entity me, vector pos)
121 me.mouseFocusedChild = NULL; // force focusing
122 if (me._changeFocusXY(me, pos))
123 if (SUPER(InputContainer).mousePress(me, pos)) return 1;
124 if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;
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;