MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / keyboardPress

Method keyboardPress

src/Interface/TextEdit.cpp:407–502  ·  view source on GitHub ↗

* Changes the text edit according to keyboard input, and * unfocuses the text if Enter is pressed. * @param action Pointer to an action. * @param state State that the action handlers belong to. */

Source from the content-addressed store, hash-verified

405 * @param state State that the action handlers belong to.
406 */
407void TextEdit::keyboardPress(Action *action, State *state)
408{
409 if (Options::keyboardMode == KEYBOARD_OFF)
410 {
411 switch (action->getDetails()->key.keysym.sym)
412 {
413 case SDLK_UP:
414 _ascii++;
415 if (_ascii > L'~')
416 {
417 _ascii = L' ';
418 }
419 break;
420 case SDLK_DOWN:
421 _ascii--;
422 if (_ascii < L' ')
423 {
424 _ascii = L'~';
425 }
426 break;
427 case SDLK_LEFT:
428 if (_value.length() > 0)
429 {
430 _value.resize(_value.length() - 1);
431 }
432 break;
433 case SDLK_RIGHT:
434 if (!exceedsMaxWidth(_ascii))
435 {
436 _value += _ascii;
437 }
438 break;
439 default: break;
440 }
441 }
442 else if (Options::keyboardMode == KEYBOARD_ON)
443 {
444 switch (action->getDetails()->key.keysym.sym)
445 {
446 case SDLK_LEFT:
447 if (_caretPos > 0)
448 {
449 _caretPos--;
450 }
451 break;
452 case SDLK_RIGHT:
453 if (_caretPos < _value.length())
454 {
455 _caretPos++;
456 }
457 break;
458 case SDLK_HOME:
459 _caretPos = 0;
460 break;
461 case SDLK_END:
462 _caretPos = _value.length();
463 break;
464 case SDLK_BACKSPACE:

Callers

nothing calls this directly

Calls 3

getDetailsMethod · 0.80
resizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected