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

 

7 Replies
Dave Cox

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.

Phil Mayor

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);

 

Joshua Bruck

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

 

Dave Cox

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.