Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
inputcontainer.qc
Go to the documentation of this file.
1#include "inputcontainer.qh"
2
3 void InputContainer_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
4 {
5 SUPER(InputContainer).resizeNotify(me, relOrigin, relSize, absOrigin, absSize);
6 //me.isTabRoot = !me.parent.instanceOfInputContainer;
7 }
8
10 {
11 SUPER(InputContainer).focusLeave(me);
12 me.mouseFocusedChild = NULL;
13 }
14
15 float InputContainer_keyDown(entity me, float scan, float ascii, float shift)
16 {
17 entity f, ff;
18 if (SUPER(InputContainer).keyDown(me, scan, ascii, shift))
19 return 1;
20 if (scan == K_ESCAPE)
21 {
22 f = me.focusedChild;
23 if (f)
24 {
25 me.setFocus(me, NULL);
26 return 1;
27 }
28 return 0;
29 }
30 if (scan == K_TAB)
31 {
32 f = me.focusedChild;
33 if (shift & S_SHIFT)
34 {
35 if (f)
36 {
37 for (ff = f.prevSibling; ff; ff = ff.prevSibling)
38 {
39 if (!ff.focusable) continue;
40 me.setFocus(me, ff);
41 return 1;
42 }
43 }
44 if (!f || me.isTabRoot)
45 {
46 for (ff = me.lastChild; ff; ff = ff.prevSibling)
47 {
48 if (!ff.focusable) continue;
49 me.setFocus(me, ff);
50 return 1;
51 }
52 return 0; // AIIIIEEEEE!
53 }
54 }
55 else
56 {
57 if (f)
58 {
59 for (ff = f.nextSibling; ff; ff = ff.nextSibling)
60 {
61 if (!ff.focusable) continue;
62 me.setFocus(me, ff);
63 return 1;
64 }
65 }
66 if (!f || me.isTabRoot)
67 {
68 for (ff = me.firstChild; ff; ff = ff.nextSibling)
69 {
70 if (!ff.focusable) continue;
71 me.setFocus(me, ff);
72 return 1;
73 }
74 return 0; // AIIIIEEEEE!
75 }
76 }
77 }
78 return 0;
79 }
80
82 {
83 entity e = this.itemFromPoint(this, pos);
84 if (e && !e.focusable) e = NULL;
85 entity prev = this.mouseFocusedChild;
86 this.mouseFocusedChild = e;
87 if (e != prev)
88 {
89 this.setFocus(this, e);
90 if (e && e.instanceOfInputContainer)
91 {
92 e.focusedChild = NULL;
93 e._changeFocusXY(e, globalToBox(pos, e.Container_origin, e.Container_size));
94 }
95 }
96 return true; // have focus
97 }
98
100 {
101 if (SUPER(InputContainer).mouseDrag(me, pos)) return 1;
102 if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;
103 return 0;
104 }
106 {
107 if (me.mouseFocusedChild != me.focusedChild) // if the keyboard moved the focus away
108 me.mouseFocusedChild = NULL; // force focusing
109 if (me._changeFocusXY(me, pos))
110 if (SUPER(InputContainer).mouseMove(me, pos)) return 1;
111 if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;
112 return 0;
113 }
115 {
116 this.mouseFocusedChild = NULL; // force focusing
117 if (this._changeFocusXY(this, pos))
118 if (SUPER(InputContainer).mousePress(this, pos)) return true;
119 if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return true;
120 return false;
121 }
123 {
124 SUPER(InputContainer).mouseRelease(me, pos); // return value?
125 if (me.focused) // am I still eligible for this? (UGLY HACK, but a mouse event could have changed focus away)
126 if (me._changeFocusXY(me, pos)) return 1;
127 if (pos.x >= 0 && pos.y >= 0 && pos.x < 1 && pos.y < 1) return 1;
128 return 0;
129 }
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
virtual void _changeFocusXY()
virtual void mousePress()
const int S_SHIFT
Definition hud.qh:129
prev
Definition all.qh:71
void InputContainer_focusLeave(entity me)
bool InputContainer__changeFocusXY(entity this, vector pos)
float InputContainer_mouseMove(entity me, vector pos)
float InputContainer_keyDown(entity me, float scan, float ascii, float shift)
void InputContainer_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
float InputContainer_mouseDrag(entity me, vector pos)
float InputContainer_mouseRelease(entity me, vector pos)
float K_TAB
Definition keycodes.qc:7
float K_ESCAPE
Definition keycodes.qc:9
vector globalToBox(vector v, vector theOrigin, vector theScale)
Definition draw.qc:30
#define SUPER(cname)
Definition oo.qh:231
#define METHOD(cname, name, prototype)
Definition oo.qh:269
#define NULL
Definition post.qh:14
vector
Definition self.qh:92