Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

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:
    27
    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:
    27
    awsapps likes this.
  3. awsapps

    awsapps

    Joined:
    Jun 15, 2021
    Posts:
    74