Forum Discussion

gindi_khangura's avatar
gindi_khangura
Occasional Contributor
10 years ago
Solved

[iOS] Close keyboard after type action

Hi,



We are typing into a TextField object in VBScript using the Keys method as we want to simulate user input, therefore SetText is not an option, and that triggers the keyboard to pop-up; however, we are unable to close the keyboard after typing.



Using Keys("[Enter]") just types it in as a literal, as do other commands like Keys("[BS]") for backspace.



We have also tried using Device.PressButton(mbkEnter/mbkEscape/mbkHome, etc). None worked except for mbkEnter, but that triggers the action associated with the control (logging in, confirming, etc) that we do not want.



All we want is to minimize the keyboard. Any suggestions?

  • Hi!



    If you want to minimize the keyboard without triggering its return action you can:

    1) Touch some other non-textual control (which closely simulates a real user action to dismiss the keyboard)

    2) Call resignFirstResponder method of the text field (which effectively does the same thing as the first approach)



    Also, just for your information, if you will ever want to also trigger the return action - just

    add either "\r" or "\n" at the end of your input:



    myField.Keys("my input\r");

4 Replies

  • Hi!



    If you want to minimize the keyboard without triggering its return action you can:

    1) Touch some other non-textual control (which closely simulates a real user action to dismiss the keyboard)

    2) Call resignFirstResponder method of the text field (which effectively does the same thing as the first approach)



    Also, just for your information, if you will ever want to also trigger the return action - just

    add either "\r" or "\n" at the end of your input:



    myField.Keys("my input\r");
  • Hi Gindi,



    Sorry about me not being clear enough. The "\r" and "\n" syntax of carriage return and line feed characters is specific for JScript. Your project is probably using some other language thus the syntax is different (for either script unit or KDT item). For example, in DelphiScript it will be like textField.Keys('qwerty'#10) and in VBScript - textField.Keys("qwerty"&Chr(10)).
  • gindi_khangura's avatar
    gindi_khangura
    Occasional Contributor
    Hi Stanislav,



    Calling resignFirstResponder did the trick.



    For your other suggestion, appending "\r" or "\n" just types them in as literals and thus does not perform the return action.



    Thanks!