void MoveContent(Vector2 pos, bool forceUpdate) { float ox = textField.x; float oy = textField.y; float nx = pos.x; float ny = pos.y; float rectWidth = _contentRect.width - 1; //-1 to avoid cursor be clipped if (rectWidth - nx > textField.textWidth) { nx = rectWidth - textField.textWidth; } if (_contentRect.height - ny > textField.textHeight) { ny = _contentRect.height - textField.textHeight; } if (nx > 0) { nx = 0; } if (ny > 0) { ny = 0; } nx = (int)nx; ny = (int)ny; if (nx != ox || ny != oy || forceUpdate) { if (_caret != null) { _caret.SetXY(nx + _caret.x - ox, ny + _caret.y - oy); _selectionShape.SetXY(nx, ny); } textField.SetXY(nx, ny); List <HtmlElement> elements = textField.htmlElements; int count = elements.Count; for (int i = 0; i < count; i++) { HtmlElement element = elements[i]; if (element.htmlObject != null) { element.htmlObject.SetPosition(element.position.x + nx, element.position.y + ny); } } } }