Copying a user entered text to a SL Variable using Java

Feb 03, 2023

Hello,

I want to copy text that is entered in a text entry field, call Input_Text_Here, to a variable called UserAns.

I have hit a roadblock, I cannot get the user-entered text to copy to the SL Variable. I have attached my SL file for people to have a look at. Can anyone help me?

I don't want to use the input entry from thing, as this is very restrictive and relies on upon submit buttons, etc. My plan is to use this copy text to the variable and then compare this variable to a text in a trigger, which will then move to the next slide.

 

Thanks

 

7 Replies
Sandeep Gadam

Hi there, if my understanding is correct, when user enters text within the provided text input field labeled as "enter text here", that value should reflect to the variable "UserAns" next to Project Var: UserAns. Am I on the right path? If yes, then add the following trigger:

Adjust variable,
UserAns to variable TextEntry
When object loses focus on "Input_text_here".

As soon as user enters the specific value that value will be reflected to this variable. Please let me know if this helps.

Math Notermans

As Sandeep states... this fixes it... However you still have to loose focus on the textfield...so click out of the textfield to activate the trigger, change the variable and go to the next page.
I do remember a question on the forum on adding entered data in an input field to a variable upon typing... so it is possible too...

Fiona O'Sullivan

Hello Math, do you know where this post is? I have tried looking for it, and this would be better, as relying on people to click 'out of the box' to confirm the entry is not the best way. I don't like the SL way of text entry checking, as it relies on the user entering the text correctly at first, and we all know we make mistakes. I am trying to do it so the user can have a natural, straightforward text entry that doesn't require them to do something abnormal in the process I am trying to teach them.

 

Thank you everyone else, I will try the fix shortly and see if it works