Search Unity

Resolved How to insert TMP Inputfield caret position inside a Rich Text tag?

Discussion in 'UGUI & TextMesh Pro' started by visca_c, Sep 25, 2021.

  1. visca_c

    visca_c

    Joined:
    Apr 7, 2014
    Posts:
    30
    I want to allow user to be able to bold text in the TMP inputfield. So I tried with the following code to position the caret inside the tag. But I noticed manipulating caretPosition will skip tags, how can I put the caret inside?

    Code (CSharp):
    1. string tag = "<b></b>";
    2. inputField.text = inputField.text.Insert(caretPosition, tag);
    3. inputField.caretPosition += 3;
     
    Last edited: Sep 25, 2021
  2. visca_c

    visca_c

    Joined:
    Apr 7, 2014
    Posts:
    30
    awsapps likes this.
  3. awsapps

    awsapps

    Joined:
    Jun 15, 2021
    Posts:
    74