Search Unity

Input field caret

Discussion in 'UGUI & TextMesh Pro' started by imaewyn, Oct 15, 2017.

  1. imaewyn

    imaewyn

    Joined:
    Apr 23, 2016
    Posts:
    211
    Hi. How can I programmatically show caret?
    Code (CSharp):
    1. inputfield.Select();
    2. inputfield.ActivateInputField();
    If I use code above I need to click on input field additionally if I want to see caret...It's not good.

    Also I don't understand why next code doesn't work while caret is visible
    Code (CSharp):
    1.   if (inputfield.isFocused &&Input.GetKeyDown(KeyCode.Return))
    2.  {
    3.       //do something
    4.  }
    5.  
    When caret is visible the state inputfield.isFocused is false. I need to press enter two times (first time for hide caret) instead one...