Forum Discussion

JoshuaBruck's avatar
JoshuaBruck
Community Member
5 years ago

Text Entry Submit on Enter

Hi all,

I know this has been asked and answered a lot, but I still seem to have great difficulty with using text entry and having the user use the [Enter] key to submit. I keep reading that if the height if the text entry is the same size as the text, it should submit when hitting enter. For me, it only seems to work when I use the original size of the text entry box. If I try to increase the font and size of the box, I am unable to do this. Is there a chart for the size of text and the matching size of font? I would appreciate any help on this.

-Josh

 

  • JoshuaBruck's avatar
    JoshuaBruck
    Community Member

    Phil, this is the answer I had been looking for. Thanks.

    Heather,

    1. Right click on the text entry box and select Format Shape.
    2. Select the Text Box tab on the left.
    3. In the Text Entry section, uncheck the Multi-line option.
  • DaveCox's avatar
    DaveCox
    Community Member

    Hi Joshua,

    I suspect the problem you are experiencing has to do with the way Storyline interprets the Enter key. When you add the Enter key to submit the text box, Storyline also enter a CR character into your text string. causing the text box to need an additional line. When I've needed to use this in the past, I've added a JavaScript function to strip the CR from the end of the text string. Then I didn't have the problem anymore.

  • DaveCox's avatar
    DaveCox
    Community Member

    Hi Josh,

    I believe that I see the issue that you are experiencing. It isn't the size of your text box that is the problem. It is just that your text isn't getting saved to the variable.

    In older versions of Storyline, you could set a trigger to submit the TextEntryBox when the user presses the Enter key, except as I explained it would cause a CR character to be entered in the text box. 

    It appears that when you set the trigger to for the Enter character, the text from the textentrybox no longer gets saved to the associated variable. The only way that I could get it to work was to use the first line from the javascript listed above. 

    document.activeElement.blur();

    This forces Storyline to loose focus on the textentrybox, and that sets the variable. From there you can proceed as normal. Of course, the javascript only runs when you publish the project.

    I believe that this behavior is a bug in Storyline, and I suggest that you submit a bug request to Articulate.

    • SchitteraSmith's avatar
      SchitteraSmith
      Community Member

      I was incredibly frustrated for about 15 minutes with this issue before searching for an answer and my goodness. All I can say is, "thank you so much!" 
      Happy Holidays! 

  • If you use a text entry question you can set the enter key to submit the interaction, shouldn't add a line return.

    If it does use this:

    document.activeElement.blur();
    var player=GetPlayer();
    var someText = player.GetVar("text_1");
    someText = someText.replace(/(\r\n|\n|\r)/gm, ""); player.SetVar("text_1", someText);

     

  • JoshuaBruck's avatar
    JoshuaBruck
    Community Member

    Hi Dave and Phil,

    Thank you so much. I am not a beginning Java user and this helps. I will definitely be using your script to remove carriage returns in the future.

    What I am looking to do is have the variable to be changed upon hitting the enter key, and I am unable to use the Text enter question for most of my projects due to needing more that one box entered per page.

    The support pages say that this can be done if the height of the text entry box is the proper height, but there is no documentation for those heights as they might match to text sizes.  

    -Josh

     

  • JoshuaBruck's avatar
    JoshuaBruck
    Community Member

    Hi Dave,

    Wow, that worked perfectly! Thank you so much. I will submit a bug request. Please have a happy new year. 

    Sincerely,

    -Josh

  • DaveCox's avatar
    DaveCox
    Community Member

    Great, I´m glad that worked out.

    Happy New Year to you as well!

    Dave

  • I know this is an older thread, but I too am having issues with this. https://360.articulate.com/review/content/a35489aa-2b5a-4312-b113-87448546223f/review

    As you can see in my Review link above, Enter creates a new line rather than submitting the value of the text entry (in this case a name). I have to click outside the box for the variable value to stick. 

    Surely, I don't need to use Javascript for basic functionality like holding a text entry variable. And I don't know how to use Javascript, so that work around won't work for me. 

    What am I missing here? I just want someone to enter their name, hit Enter and have that name carry throughout...pretty typical. Thanks for any insight!

    • PhilMayor's avatar
      PhilMayor
      Super Hero

      Ignore me there may be a simple solution. Open the text properties and set it to one line and then add a trigger to submit (or what ever action you want) when user presses the enter key.
      Sent from my iPhone

      • HeatherVogt-d32's avatar
        HeatherVogt-d32
        Community Member

        Thanks for your quick response! I don't know what you mean by "text properties" though. Sorry!