added setCaretPos function