MCPcopy Create free account
hub / github.com/axmolengine/axmol / setCursorFromPoint

Method setCursorFromPoint

core/2d/TextFieldTTF.cpp:395–435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393}
394
395void 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
437void TextFieldTTF::setAttachWithIME(bool isAttachWithIME)
438{

Callers

nothing calls this directly

Calls 4

isScreenPointInRectFunction · 0.85
Vec2Class · 0.70
getContentSizeMethod · 0.45

Tested by

no test coverage detected