Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

InputField.caretPosition not working on iOS with mobile input hidden

Discussion in 'UGUI & TextMesh Pro' started by Xyra, Sep 11, 2015.

  1. Xyra

    Xyra

    Joined:
    Jul 18, 2012
    Posts:
    17
    I've created a script to allow you to tap on the screen to position the caret within an InputField on iOS by tapping on letters in the field.

    The caret positions perfectly before or after the letter by setting InputField.caretPosition, however as soon as you start typing again the caret jumps to the end of the line and the text appends to the line rather than adding in where the caret is.

    Any one else found this, or have a work around?
     
  2. Xyra

    Xyra

    Joined:
    Jul 18, 2012
    Posts:
    17
    Submitted a bug:
    726802
     
  3. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,161
    This has been a known issue for a while so i'm closing your bug as a duplicate.

    This issue is that the touch screen keyboard has no way of positioning the caret on the device and the device always sets the caret to the end. Its something i'm working on but is something i need to implement on multiple devices which takes time.
     
  4. Xyra

    Xyra

    Joined:
    Jul 18, 2012
    Posts:
    17
    Fair enough, thanks for taking the time to look.

    I might try and implement a workaround - perhaps store the last caret position at the end of late update and check for changes to the .text value in the field. If it finds any then it resets the caret and puts the text at the last known position? Might be flickery though if the text extends past the end of the box I suppose
     
  5. phil-Unity

    phil-Unity

    Unity UI Lead Developer Unity Technologies

    Joined:
    Nov 23, 2012
    Posts:
    1,161
    If you can find a work around by all means use it as i don't know when i'll be able to get this work released.
     
  6. roclau0102

    roclau0102

    Joined:
    Oct 11, 2014
    Posts:
    6
    Is that has been solved?
     
  7. twiggs1

    twiggs1

    Joined:
    Jul 6, 2018
    Posts:
    6
    Yeah not sure if this has been solved yet
     
  8. jpair

    jpair

    Joined:
    Jan 3, 2019
    Posts:
    3
    Does anyone know if the caret positioning has been fixed or have a working solution? I have an InputField which works fine when playing inside the Editor. However, when I build and deploy to my iOS device, the behavior is not like any other form field I've seen in other languages. If you start typing in the field and mobile click somewhere in the typed text area to make a correction, the cursor appears to be located where you clicked until you start typing again, at which point all edits are applied starting at the end of the text line. I've tried lots of options like keyboardType, setting caretPosition, etc but nothing seems to work. Does anyone have a workaround or ideas on what I'm doing wrong? I'm using Unity 2018.3 Pro version if that matters. Starting an upgrade to 2019.3.6 to see if problem exists in this version. Thanks for any help or advice.
     
  9. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,974
    What version of the TMP package are you using?

    Please test with the latest version which is 2.1.0-preview.8 for Unity 2019.x.
     
  10. jpair

    jpair

    Joined:
    Jan 3, 2019
    Posts:
    3
    Stephan_B, I'm using TMP 1.3.0 - will upgrade and try newer version. Thank you for recommendation. Will reply if this fixes the problem.
     
  11. jpair

    jpair

    Joined:
    Jan 3, 2019
    Posts:
    3
    Hi Stephan_B, I upgraded from 2018.3 to 2019.3 which include the newer TMP version. Works like a charm on iOS mobile now. Thank you. As is often the case with upgrades though, it didn't come without a few hurdles to solve. Glad to have it working with 2019. Thanks again!
     
unityunity