| 387 | } |
| 388 | |
| 389 | void EditBox::onKeyButtonPressed(KeyCode _key, Char _char) |
| 390 | { |
| 391 | if (mClientText == nullptr || getClientWidget() == nullptr) |
| 392 | { |
| 393 | Base::onKeyButtonPressed(_key, _char); |
| 394 | return; |
| 395 | } |
| 396 | |
| 397 | // в статическом режиме ничего не доступно |
| 398 | if (mModeStatic) |
| 399 | { |
| 400 | Base::onKeyButtonPressed(_key, _char); |
| 401 | return; |
| 402 | } |
| 403 | |
| 404 | InputManager& input = InputManager::getInstance(); |
| 405 | |
| 406 | mClientText->setVisibleCursor(true); |
| 407 | mCursorTimer = 0.0f; |
| 408 | |
| 409 | auto editCmd = ToEditCommand(_key, input); |
| 410 | |
| 411 | if (editCmd == EditCommand::LoseFocus) |
| 412 | { |
| 413 | InputManager::getInstance().setKeyFocusWidget(nullptr); |
| 414 | } |
| 415 | else if (editCmd == EditCommand::ErasePrevious) |
| 416 | { |
| 417 | // если нуно то удаляем выделенный текст |
| 418 | if (!mModeReadOnly) |
| 419 | { |
| 420 | // сбрасываем повтор |
| 421 | commandResetRedo(); |
| 422 | |
| 423 | if (!deleteTextSelect(true)) |
| 424 | { |
| 425 | // прыгаем на одну назад и удаляем |
| 426 | if (mCursorPosition != 0) |
| 427 | { |
| 428 | mCursorPosition--; |
| 429 | eraseText(mCursorPosition, 1, true); |
| 430 | } |
| 431 | } |
| 432 | // отсылаем событие о изменении |
| 433 | eventEditTextChange(this); |
| 434 | } |
| 435 | } |
| 436 | else if (editCmd == EditCommand::EraseNext) |
| 437 | { |
| 438 | if (!mModeReadOnly) |
| 439 | { |
| 440 | // сбрасываем повтор |
| 441 | commandResetRedo(); |
| 442 | |
| 443 | // если нуно то удаляем выделенный текст |
| 444 | if (!deleteTextSelect(true)) |
| 445 | { |
| 446 | if (mCursorPosition != mTextLength) |
nothing calls this directly
no test coverage detected