Mercurial > hg > ristipolku
comparison game/IDMContainer.java @ 175:55ea5821c802
Implement "real" widget modality.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 16 Mar 2017 10:42:54 +0200 |
parents | f664e851bc07 |
children | 4568c8016377 |
comparison
equal
deleted
inserted
replaced
174:92df534806c4 | 175:55ea5821c802 |
---|---|
81 } | 81 } |
82 } | 82 } |
83 | 83 |
84 synchronized public boolean mousePressed(MouseEvent e) | 84 synchronized public boolean mousePressed(MouseEvent e) |
85 { | 85 { |
86 IDMWidget modal = getActiveModalWidget(); | |
87 if (modal != null) | |
88 return modal.mousePressed(e); | |
89 | |
86 try { | 90 try { |
87 beginIteration(); | 91 beginIteration(); |
88 for (IDMWidget widget : children) | 92 for (IDMWidget widget : children) |
89 { | 93 { |
90 if (widget.contains(e.getPoint())) | 94 if (widget.contains(e.getPoint())) |
98 return false; | 102 return false; |
99 } | 103 } |
100 | 104 |
101 synchronized public boolean mouseReleased(MouseEvent e) | 105 synchronized public boolean mouseReleased(MouseEvent e) |
102 { | 106 { |
107 IDMWidget modal = getActiveModalWidget(); | |
108 if (modal != null) | |
109 return modal.mouseReleased(e); | |
110 | |
103 try { | 111 try { |
104 beginIteration(); | 112 beginIteration(); |
105 for (IDMWidget widget : children) | 113 for (IDMWidget widget : children) |
106 { | 114 { |
107 if (widget.mouseReleased(e)) | 115 if (widget.mouseReleased(e)) |
112 return false; | 120 return false; |
113 } | 121 } |
114 | 122 |
115 synchronized public boolean mouseExited(MouseEvent e) | 123 synchronized public boolean mouseExited(MouseEvent e) |
116 { | 124 { |
125 IDMWidget modal = getActiveModalWidget(); | |
126 if (modal != null) | |
127 return modal.mouseExited(e); | |
128 | |
117 try { | 129 try { |
118 beginIteration(); | 130 beginIteration(); |
119 for (IDMWidget widget : children) | 131 for (IDMWidget widget : children) |
120 { | 132 { |
121 if (widget.mouseExited(e)) | 133 if (widget.mouseExited(e)) |
126 return false; | 138 return false; |
127 } | 139 } |
128 | 140 |
129 synchronized public boolean mouseEntered(MouseEvent e) | 141 synchronized public boolean mouseEntered(MouseEvent e) |
130 { | 142 { |
143 IDMWidget modal = getActiveModalWidget(); | |
144 if (modal != null) | |
145 return modal.mouseEntered(e); | |
146 | |
131 try { | 147 try { |
132 beginIteration(); | 148 beginIteration(); |
133 for (IDMWidget widget : children) | 149 for (IDMWidget widget : children) |
134 { | 150 { |
135 if (widget.contains(e.getPoint())) | 151 if (widget.contains(e.getPoint())) |
143 return false; | 159 return false; |
144 } | 160 } |
145 | 161 |
146 synchronized public boolean keyPressed(KeyEvent e) | 162 synchronized public boolean keyPressed(KeyEvent e) |
147 { | 163 { |
164 IDMWidget modal = getActiveModalWidget(); | |
165 if (modal != null) | |
166 return modal.keyPressed(e); | |
167 | |
148 try { | 168 try { |
149 beginIteration(); | 169 beginIteration(); |
150 for (IDMWidget widget : children) | 170 for (IDMWidget widget : children) |
151 { | 171 { |
152 if (widget.keyPressed(e)) | 172 if (widget.keyPressed(e)) |
184 if (widget == o) | 204 if (widget == o) |
185 return true; | 205 return true; |
186 } | 206 } |
187 return false; | 207 return false; |
188 } | 208 } |
209 | |
210 synchronized public IDMWidget getActiveModalWidget() | |
211 { | |
212 for (IDMWidget widget : children) | |
213 { | |
214 if (widget.isModal()) | |
215 return widget; | |
216 } | |
217 return null; | |
218 } | |
189 } | 219 } |