MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / HandleEvent

Method HandleEvent

neo/ui/EditWindow.cpp:192–429  ·  view source on GitHub ↗

============= idEditWindow::HandleEvent ============= */

Source from the content-addressed store, hash-verified

190=============
191*/
192const char *idEditWindow::HandleEvent(const sysEvent_t *event, bool *updateVisuals) {
193 static char buffer[ MAX_EDITFIELD ];
194 const char *ret = "";
195
196 if ( wrap ) {
197 // need to call this to allow proper focus and capturing on embedded children
198 ret = idWindow::HandleEvent( event, updateVisuals );
199 if ( ret && *ret ) {
200 return ret;
201 }
202 }
203
204 if ( ( event->evType != SE_CHAR && event->evType != SE_KEY ) ) {
205 return ret;
206 }
207
208 idStr::Copynz( buffer, text.c_str(), sizeof( buffer ) );
209 int key = event->evValue;
210 int len = text.Length();
211
212 if ( event->evType == SE_CHAR ) {
213 if ( event->evValue == Sys_GetConsoleKey( idKeyInput::IsDown( K_SHIFT ) ) ) {
214 return "";
215 }
216
217 if ( updateVisuals ) {
218 *updateVisuals = true;
219 }
220
221 if ( maxChars && len > maxChars ) {
222 len = maxChars;
223 }
224
225 if ( ( key == K_ENTER || key == K_KP_ENTER ) && event->evValue2 ) {
226 RunScript( ON_ACTION );
227 RunScript( ON_ENTER );
228 return cmd;
229 }
230
231 if ( key == K_ESCAPE ) {
232 RunScript( ON_ESC );
233 return cmd;
234 }
235
236 if ( readonly ) {
237 return "";
238 }
239
240 if ( key == 'h' - 'a' + 1 || key == K_BACKSPACE ) { // ctrl-h is backspace
241 if ( cursorPos > 0 ) {
242 if ( cursorPos >= len ) {
243 buffer[len - 1] = 0;
244 cursorPos = len - 1;
245 } else {
246 memmove( &buffer[ cursorPos - 1 ], &buffer[ cursorPos ], len + 1 - cursorPos);
247 cursorPos--;
248 }
249

Callers

nothing calls this directly

Calls 8

Sys_GetConsoleKeyFunction · 0.85
GetOverStrikeMethod · 0.80
SetOverStrikeMethod · 0.80
c_strMethod · 0.45
LengthMethod · 0.45
NumMethod · 0.45
SetValueMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected