Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Input Field shows text as hilighted - make it stop

Discussion in 'UGUI & TextMesh Pro' started by judy3turn, Jan 13, 2015.

  1. judy3turn

    judy3turn

    Joined:
    Aug 16, 2012
    Posts:
    13
    I have an input field which I activate when it is time for the user to start typing. I want them to type in newlines so I set it to mutli-line with new lines. Then I put a FINISHED button which takes the text, stores it, and ends the typing.

    At first, I had to click in the input field to start typing, but when I hit FINISHED it worked correctly. I wanted to skip the click in the input field so I set the input field as selected with

    EventSystem.current.SetSelectedGameObject(letterInput.gameObject, null);
    Then upon hitting FINISHED instead of having everything as typed, all the text that the user types in is hilighted. I don't want it hilighted. I want it left alone.

    So upon hitting FINISHED I tried

    EventSystem.current.SetSelectedGameObject(null);
    (I also tried setting it to a different object with the same results).

    The test is still showing up as hilighted. If I click in the input field, the hilight goes away but that's also not ideal.

    IDEALLY I would like to have the cursor in the input field as happens when call SetSelectedGameObject and then when I click finish the input field would just show the text as it was written rather than hilight it. How do I make that happen?
     
  2. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    call MoveTextEnd() after setting it selected.
     
  3. dwp9123

    dwp9123

    Joined:
    May 23, 2017
    Posts:
    2
    But it does not work! Is there any other method?
     
  4. dwp9123

    dwp9123

    Joined:
    May 23, 2017
    Posts:
    2
    Do you solve this problem now? If yes, please send email dwp9123@qq.com . Thank you very much
     
  5. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Certainly not going to email you, but I have a couple of options.
    First option is part of something else I once worked on, and it involved subclassing the inputfield, and in there, I called a coroutine which waited until the end of the frame and then did "MoveTextEnd(false)". Guess you could also do this through an event, too.
    Second option: Get TextMeshPro (free now from the asset store, and sometime soon integrated into Unity), which I'm 99% sure has the ability to turn that off right there as a checkbox :)