2 CLASS(InputContainer) EXTENDS(Container)
3 METHOD(InputContainer, keyDown, float(entity, float, float, float))
4 METHOD(InputContainer, mouseMove, float(entity, vector))
5 METHOD(InputContainer, mousePress, float(entity, vector))
6 METHOD(InputContainer, mouseRelease, float(entity, vector))
7 METHOD(InputContainer, mouseDrag, float(entity, vector))
8 METHOD(InputContainer, focusLeave, void(entity))
9 METHOD(InputContainer, resizeNotify, void(entity, vector, vector, vector, vector))
11 METHOD(InputContainer, _changeFocusXY, float(entity, vector))
12 ATTRIB(InputContainer, mouseFocusedChild, entity, NULL)
13 ATTRIB(InputContainer, isTabRoot, float, 0)
14 ENDCLASS(InputContainer)
18 void InputContainer_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
20 SUPER(InputContainer).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
22 if(me.parent.instanceOfInputContainer)
29 void InputContainer_focusLeave(entity me)
31 SUPER(InputContainer).focusLeave(me);
32 me.mouseFocusedChild = NULL;
35 float InputContainer_keyDown(entity me, float scan, float ascii, float shift)
38 if(SUPER(InputContainer).keyDown(me, scan, ascii, shift))
45 me.setFocus(me, NULL);
57 for(ff = f.prevSibling; ff; ff = ff.prevSibling)
65 if(!f || me.isTabRoot)
67 for(ff = me.lastChild; ff; ff = ff.prevSibling)
74 return 0; // AIIIIEEEEE!
81 for(ff = f.nextSibling; ff; ff = ff.nextSibling)
89 if(!f || me.isTabRoot)
91 for(ff = me.firstChild; ff; ff = ff.nextSibling)
98 return 0; // AIIIIEEEEE!
105 float InputContainer__changeFocusXY(entity me, vector pos)
108 e = me.mouseFocusedChild;
109 ne = me.itemFromPoint(me, pos);
113 me.mouseFocusedChild = ne;
118 if(ne.instanceOfInputContainer)
120 ne.focusedChild = NULL;
121 ne._changeFocusXY(e, globalToBox(pos, ne.Container_origin, ne.Container_size));
127 float InputContainer_mouseDrag(entity me, vector pos)
129 if(SUPER(InputContainer).mouseDrag(me, pos))
131 if(pos_x >= 0 && pos_y >= 0 && pos_x < 1 && pos_y < 1)
135 float InputContainer_mouseMove(entity me, vector pos)
137 if(me._changeFocusXY(me, pos))
138 if(SUPER(InputContainer).mouseMove(me, pos))
140 if(pos_x >= 0 && pos_y >= 0 && pos_x < 1 && pos_y < 1)
144 float InputContainer_mousePress(entity me, vector pos)
146 me.mouseFocusedChild = NULL; // force focusing
147 if(me._changeFocusXY(me, pos))
148 if(SUPER(InputContainer).mousePress(me, pos))
150 if(pos_x >= 0 && pos_y >= 0 && pos_x < 1 && pos_y < 1)
154 float InputContainer_mouseRelease(entity me, vector pos)
156 SUPER(InputContainer).mouseRelease(me, pos); // return value?
157 if(me.focused) // am I still eligible for this? (UGLY HACK, but a mouse event could have changed focus away)
158 if(me._changeFocusXY(me, pos))
160 if(pos_x >= 0 && pos_y >= 0 && pos_x < 1 && pos_y < 1)