Forum Discussion

AprilDrennan-f8's avatar
AprilDrennan-f8
Community Member
9 months ago

variables with text entry help

Hi. I am not sure if what I am asking is possible. The user is supposed to type the number 68 into an input box. Once they type that number, I want a red lined shape to appear around another area of the screen , but only if 68 has been typed. I don't want the user to have to click anywhere once the 68 has been typed. As soon as the 8 is typed, the other rectangle shape should appear. Thanks.

  • SBP_Inc's avatar
    SBP_Inc
    Community Member

    Triggers do not fire on individual keystrokes, but I was able to get close to your ask. I created a variable called "entered", connect a text input to that variable, then show the "redbox" layer using a Show Layer trigger with conditions [when variable changes; entered == 68] . The layer shows only after ENTER.

    • AprilDrennan-f8's avatar
      AprilDrennan-f8
      Community Member

      Did you create and upload a file? I don't see it, unless I'm looking in the wrong place. Or am I just following your instructions. In either case, thank you!

  • April, Brian's solution will probably do what you want.

    However, if anyone wants to trigger something directly from the value you type into an input text box, then you can do something like this. In the example, as you type into the box, the current value is displayed. When it matches the target value that you set, the red box is triggered. No pressing enter or clicking required. 

    https://360.articulate.com/review/content/35f36820-20f1-4e4e-ab5b-97b9342f490e/review

    It uses a small piece of JavaScript to "listen" for changes to the input box's contents. It doesn't need to have them committed before it can respond. The event listener is only active when the input box has focus.

    • TanyaStillman-7's avatar
      TanyaStillman-7
      Community Member

      Thanks, Nathan! This solution provided me with exactly what I needed! I just copied your example slide into my story and changed the target value to what I needed. You're fabulous!

    • TanyaStillman-7's avatar
      TanyaStillman-7
      Community Member

      Next challenge, Nathan_Hillard! If I copy your excellent example more than once in a story, the 2nd slide doesn't function properly. I suspect it has to do with the single txtInput variable. I know nothing about Java, so can't determine if that's the issue.

      • Nathan_Hilliard's avatar
        Nathan_Hilliard
        Community Member

        Yes, that example only located the first input box. I modifed it (attached) so you can specify a name for each text entry (right click text entry in timeline, select Accessibility). Give each text entry a unique Alt Text name. Set this name also in the inputTagName variable (top trigger on each slide). Set the targetValue variable in the trigger list too. Now it should locate the input you specify on each slide and compare it to the indicated target value.

        If you wanted more than one per slide, you would need some extra variables to track the tag names and target values for each.