| 638 | } |
| 639 | |
| 640 | void TextFieldTTF::controlKey(EventKeyboard::KeyCode keyCode) |
| 641 | { |
| 642 | if (_cursorEnabled) |
| 643 | { |
| 644 | switch (keyCode) |
| 645 | { |
| 646 | case EventKeyboard::KeyCode::KEY_HOME: |
| 647 | case EventKeyboard::KeyCode::KEY_KP_HOME: |
| 648 | setCursorPosition(0); |
| 649 | updateCursorDisplayText(); |
| 650 | break; |
| 651 | case EventKeyboard::KeyCode::KEY_END: |
| 652 | setCursorPosition(_charCount); |
| 653 | updateCursorDisplayText(); |
| 654 | break; |
| 655 | case EventKeyboard::KeyCode::KEY_DELETE: |
| 656 | case EventKeyboard::KeyCode::KEY_KP_DELETE: |
| 657 | if (_cursorPosition < (std::size_t)_charCount) |
| 658 | { |
| 659 | std::string sText(_inputText); |
| 660 | auto nb = StringUtils::eraseUTF8CharAt(sText, _cursorPosition); |
| 661 | if (nb) |
| 662 | --_charCount; |
| 663 | setCursorPosition(_cursorPosition); |
| 664 | |
| 665 | setString(sText); |
| 666 | } |
| 667 | break; |
| 668 | case EventKeyboard::KeyCode::KEY_LEFT_ARROW: |
| 669 | if (_cursorPosition) |
| 670 | { |
| 671 | setCursorPosition(_cursorPosition - 1); |
| 672 | updateCursorDisplayText(); |
| 673 | } |
| 674 | break; |
| 675 | case EventKeyboard::KeyCode::KEY_RIGHT_ARROW: |
| 676 | if (_cursorPosition < (std::size_t)_charCount) |
| 677 | { |
| 678 | setCursorPosition(_cursorPosition + 1); |
| 679 | updateCursorDisplayText(); |
| 680 | } |
| 681 | break; |
| 682 | case EventKeyboard::KeyCode::KEY_ESCAPE: |
| 683 | detachWithIME(); |
| 684 | break; |
| 685 | default: |
| 686 | break; |
| 687 | } |
| 688 | } |
| 689 | } |
| 690 | |
| 691 | std::string_view TextFieldTTF::getString() const |
| 692 | { |
no test coverage detected