| 393 | } |
| 394 | |
| 395 | void TextFieldTTF::setCursorFromPoint(const Vec2& point, const Camera* camera) |
| 396 | { |
| 397 | if (_cursorEnabled) |
| 398 | { |
| 399 | // Reset Label, no cursor |
| 400 | bool oldIsAttachWithIME = _isAttachWithIME; |
| 401 | _isAttachWithIME = false; |
| 402 | updateCursorDisplayText(); |
| 403 | |
| 404 | Rect rect; |
| 405 | rect.size = getContentSize(); |
| 406 | if (isScreenPointInRect(point, camera, getWorldToNodeTransform(), rect, nullptr)) |
| 407 | { |
| 408 | int latterPosition = 0; |
| 409 | for (; latterPosition < _lengthOfString; ++latterPosition) |
| 410 | { |
| 411 | if (_lettersInfo[latterPosition].valid && _lettersInfo[latterPosition].atlasIndex >= 0) |
| 412 | { |
| 413 | auto sprite = getLetter(latterPosition); |
| 414 | if (sprite) |
| 415 | { |
| 416 | rect.size = Vec2(sprite->getContentSize().width, _lineHeight); |
| 417 | if (isScreenPointInRect(point, camera, sprite->getWorldToNodeTransform(), rect, nullptr)) |
| 418 | { |
| 419 | setCursorPosition(latterPosition); |
| 420 | break; |
| 421 | } |
| 422 | } |
| 423 | } |
| 424 | } |
| 425 | if (latterPosition == _lengthOfString) |
| 426 | { |
| 427 | setCursorPosition(latterPosition); |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | // Set cursor |
| 432 | _isAttachWithIME = oldIsAttachWithIME; |
| 433 | updateCursorDisplayText(); |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | void TextFieldTTF::setAttachWithIME(bool isAttachWithIME) |
| 438 | { |
nothing calls this directly
no test coverage detected