Text Entry Wildcard/Lose Focus workaround
Have you ever found yourself wanting to evaluate a Text Entry field WHILE the user was typing? Frustrated by the inability to do that? Me too.
I stumbled upon something today that didn't work as I expected it to, but might be a workaround. Here is the situation: I'm creating a simulation where I want the user to enter "2541261" in a text entry field. If this was a stand-alone task, I would simply add a "submit" button of some kind and evaluate the entry when the button is clicked. However, this is just one of a series of steps, so I don't want that additional button. Rather once the number is entered, the instructions for the next step should appear.
In a previous version, the user was supposed to enter a different number: "2541263", so I simply assumed they typed in the correct number and triggered something when the user pressed 3 key or Num 3 key. Not ideal, but it worked.
I can't do this with the new version, since the user has to press the 1 key or the Num 1 key twice. I attempted to work around by counting the number of times the 1 key or the Num 1 key were pressed, by creating a variable (inputCharCount) and incrementing it (+1) each time the 1 key or Num1 key are pressed.
Here's where it gets interesting...
The variable doesn't increment when I hit the 1 key. Instead, it is assigned whatever has been entered in the text field before the 1 is pressed. The control hasn't lost focus yet, so the TextEntry variable is still undefined, yet I can test whatever the user has typed.
...possibilities!
A few notes:
- In my example, the inputCharCount variable is set to be a number, so entering other characters messes things up.
- Even though the trigger occurs when the user presses 1, it only captures everything up to, but not including the last "1" (difference between key down and key up?)
- I'm only testing the entered text in a rudimentary manner (i.e. inputCharCount >= 254126), but you could do something more sophisticated, including searching strings via javascript.
- Haven't tested on iOS yet.
check it out:
http://www.deus-ex-media.com/experiments/storyline/text_entry_wildcard/package/story.html
Maybe this isn't news to anyone, but I hadn't seen it before.
Also interested in any other ways you guys have been doing this sort of thing.
thanks!
1 Reply
Thanks David for sharing your explanation plus providing a copy of the .story file here for folks to take a look at. It's a common enough question that even if it's been answered before it's great to have here again.