PennController for IBEX › Forums › Support › Several questions about the TextInput element › Reply To: Several questions about the TextInput element
Hello Matthias,
1) As you noticed, the latest printed TextInput element is the one that gets focused by default. Just print the TextInput that you want to auto-focus last, e.g: getTextInput("inputAlter").print( 400, 0, getCanvas("Canvas") )
2) There is no straightforward way to do that for TextInput elements in PennController. You’d have to inject some HTML and find a way to save its value, like this for example: newHtml("alter", "<input type='number' id='alter' name='alter' min='1' max='120'>").print( 400, 0, getCanvas("Canvas") ). Then of course you’ll need to adapt any test you had on TextInput so it now checks the value of the HTML input element (e.g. newFunction( ()=>$("#alter").val().match(/^\d+$/) ).testNot.is(null)) and if you need to set a Var element, this is what you’d do: newVar("Alter").global().set( v=>$("#alter").val() )
3) See point above if you want to use native-HTML features
4) You can use .log("all") but then the format of the lines in the results file is special. You get four lines for one TextInput element beside the “Final” one, with the relevant information reported in the Comments column for three of them. One line reports how many key presses there were, one line reports the successive Keys that were pressed, one line reports the timecodes of each of those key presses, and one line reports the content of the input box after each of those key presses. The values are separated by commas, coded as %2C to prevent artificially adding extra columns to the results file.
Example:
1604596974,MD5,PennController,0,0,Angaben,NULL,TextInput,inputGeboren,NTypingEvents,8,1604596936977,33,weiblich,rechtshändig,Travail,sadfsad,nein,saddsf,asdfdsa,All saved%2C see documentation 1604596974,MD5,PennController,0,0,Angaben,NULL,TextInput,inputGeboren,TypingEvent,Keys,NULL,33,weiblich,rechtshändig,Travail,sadfsad,nein,saddsf,asdfdsa,Shift%2CT%2Cr%2Ca%2Cv%2Ca%2Ci%2Cl 1604596974,MD5,PennController,0,0,Angaben,NULL,TextInput,inputGeboren,TypingEvent,Texts,NULL,33,weiblich,rechtshändig,Travail,sadfsad,nein,saddsf,asdfdsa,%2C%2CT%2CTr%2CTra%2CTrav%2CTrava%2CTravai 1604596974,MD5,PennController,0,0,Angaben,NULL,TextInput,inputGeboren,TypingEvent,Times,NULL,33,weiblich,rechtshändig,Travail,sadfsad,nein,saddsf,asdfdsa,1604596929424%2C1604596930876%2C1604596931456%2C1604596931566%2C1604596931782%2C1604596931866%2C1604596932002%2C1604596932132
It’s ugly, but it’s easy to parse in R, for example, by splitting the Comments column using %2C. In this example, you can see from the second line that my first key press was the Shift key, and my second key press was the key T. The last line tells me that I pressed T 1604596930876-1604596929424=1452ms after I pressed Shift
Let me know if you have questions
Jeremy