コード例 #1
0
        public override void OnDrag(PointerEventData eventData)
        {
            Vector2 localMousePos = EditableText.MousePositionInTextRect(eventData);

            if (localMousePos.x < EditableText.DisplayRect.xMin)
            {
                MoveCaretWithinBounds(Caret.GetIndex() - 1, true);
                UpdateText();
            }
            else if (localMousePos.x > EditableText.DisplayRect.xMax)
            {
                MoveCaretWithinBounds(Caret.GetIndex() + 1, true);
                UpdateText();
            }
            else
            {
                MoveCaretWithinBounds(EditableText.RelativeIndexFromPosition(localMousePos) + _drawStart, true);
                InputFieldController.MarkGeometryAsDirty();
            }

            eventData.Use();
        }