Forum Discussion

gberge's avatar
gberge
Occasional Contributor
2 years ago
Solved

Clearing a textbox in mobile devices in script

I have a problem where I need to enter in new text in a control that already has some text in it

 

I tried the following to overwrite the existing text:

 

  // Select the existing text in the texbox
  textbox.LongTouch(10, textbox.Height / 2)

  // Enter new text
  textbox.Keys(text);

 

While the LongTouch method does select all the text in the textbox, following it with the Keys method still appends the new text to the existing text.

  • You can always try several backspaces.  Also, "may fail" wouldn't keep me from trying it if it was my test, but that's up to you.

     

    If you were performing this action manually, what would you do to clear the space?

     

     

  • gberge's avatar
    gberge
    2 years ago

    I was wrong about iOS. The Keys method for iOS devices does seem to delete the existing text in the control prior to entering the new text. I thought that I saw the same behaviour between Android and iOS but apparently I was wrong.

     

    The Keys method doesn't delete the existing text on Android devices but this is fixed by first entering multiple backspaces.

7 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Try a backspace to clear the text once it's been selected.

      • Marsha_R's avatar
        Marsha_R
        Champion Level 3

        You can always try several backspaces.  Also, "may fail" wouldn't keep me from trying it if it was my test, but that's up to you.

         

        If you were performing this action manually, what would you do to clear the space?