| 289 | } |
| 290 | |
| 291 | void TextEntry::OnKeyPressed(int key, bool isRepeat) |
| 292 | { |
| 293 | if (key == OF_KEY_RETURN) |
| 294 | { |
| 295 | AcceptEntry(true); |
| 296 | IKeyboardFocusListener::ClearActiveKeyboardFocus(!K(notifyListeners)); |
| 297 | } |
| 298 | else if (key == OF_KEY_TAB) |
| 299 | { |
| 300 | TextEntry* pendingNewEntry = nullptr; |
| 301 | if (GetKeyModifiers() == kModifier_Shift) |
| 302 | pendingNewEntry = mPreviousTextEntry; |
| 303 | else |
| 304 | pendingNewEntry = mNextTextEntry; |
| 305 | |
| 306 | AcceptEntry(false); |
| 307 | IKeyboardFocusListener::ClearActiveKeyboardFocus(!K(notifyListeners)); |
| 308 | |
| 309 | if (pendingNewEntry) |
| 310 | { |
| 311 | pendingNewEntry->MakeActiveTextEntry(true); |
| 312 | pendingNewEntry->SelectAll(); |
| 313 | } |
| 314 | } |
| 315 | else if (key == juce::KeyPress::backspaceKey) |
| 316 | { |
| 317 | int len = (int)strlen(mString); |
| 318 | if (mCaretPosition != mCaretPosition2) |
| 319 | { |
| 320 | RemoveSelectedText(); |
| 321 | } |
| 322 | else if (mCaretPosition > 0) |
| 323 | { |
| 324 | for (int i = mCaretPosition - 1; i < len; ++i) |
| 325 | mString[i] = mString[i + 1]; |
| 326 | --mCaretPosition; |
| 327 | --mCaretPosition2; |
| 328 | } |
| 329 | } |
| 330 | else if (key == juce::KeyPress::deleteKey) |
| 331 | { |
| 332 | int len = (int)strlen(mString); |
| 333 | if (mCaretPosition != mCaretPosition2) |
| 334 | { |
| 335 | RemoveSelectedText(); |
| 336 | } |
| 337 | else |
| 338 | { |
| 339 | for (int i = mCaretPosition; i < len; ++i) |
| 340 | mString[i] = mString[i + 1]; |
| 341 | } |
| 342 | } |
| 343 | else if (key == OF_KEY_ESC || key == '`') |
| 344 | { |
| 345 | IKeyboardFocusListener::ClearActiveKeyboardFocus(K(notifyListeners)); |
| 346 | mCaretPosition2 = mCaretPosition; |
| 347 | } |
| 348 | else if (key == OF_KEY_LEFT) |
nothing calls this directly
no test coverage detected