| 36 | } |
| 37 | |
| 38 | std::string KeyboardManager::text(const std::string& suggestion, const std::string& hint, size_t maxLen) |
| 39 | { |
| 40 | SwkbdState swkbd; |
| 41 | const size_t kBufSize = 64; |
| 42 | size_t limit = std::min(maxLen, kBufSize); |
| 43 | if (limit < 2) { |
| 44 | limit = 2; |
| 45 | } |
| 46 | swkbdInit(&swkbd, SWKBD_TYPE_NORMAL, 2, limit - 1); |
| 47 | swkbdSetValidation(&swkbd, SWKBD_NOTBLANK_NOTEMPTY, 0, 0); |
| 48 | swkbdSetInitialText(&swkbd, suggestion.c_str()); |
| 49 | swkbdSetHintText(&swkbd, hint.c_str()); |
| 50 | char buf[kBufSize] = {0}; |
| 51 | SwkbdButton button = swkbdInputText(&swkbd, buf, sizeof(buf)); |
| 52 | buf[sizeof(buf) - 1] = '\0'; |
| 53 | return button == SWKBD_BUTTON_CONFIRM ? std::string(buf) : std::string(); |
| 54 | } |
| 55 | |
| 56 | int KeyboardManager::numpad(const std::string& hint, int min, int max) |
| 57 | { |
no test coverage detected