By Lingi - 4/2/2018
Hi everyone, I would like to dynamically change the textcolor via expressions as I do for the text that is presented - but this does not work. Does anybody know whether there is a bug in my script or if there is any other way to dynamically change the textcolor of an element depending on conditions? Thank you for your help!
<text newTaskReminder> / items = ("<%expressions.new_task_reminder%>") / position = (50%, 80%) / txcolor = <%expressions.newTaskReminderColor%> / size = (80%, 6%) / fontstyle = ("Arial", 3%, false, false, false, false, 5, 1) </text>
<expressions> /new_task_reminder={ if(values.targetTask == values.taskA) { "BUCHSTABE ~n '<%text.letter.#ff2e50%>' ~n'<%parameters.leftKeyLabel%>': <%expressions.letter_left%> '<%parameters.rightKeyLabel%>': <%expressions.letter_right%>"; } else if (values.targetTask == values.taskB) { "ZAHL ~n '<%text.number.#ff2e50%>' ~n'<%parameters.leftKeyLabel%>': <%expressions.number_left%> '<%parameters.rightKeyLabel%>': <%expressions.number_right%>"; } else { "?????????"; } }
/newTaskReminderColor={ if(values.targetTask == values.taskA) { darkmagenta; } else if (values.targetTask == values.taskB) { limegreen; } else { orangered; } }
</expressions>
|
By Dave - 4/3/2018
+xHi everyone, I would like to dynamically change the textcolor via expressions as I do for the text that is presented - but this does not work. Does anybody know whether there is a bug in my script or if there is any other way to dynamically change the textcolor of an element depending on conditions? Thank you for your help! <text newTaskReminder> / items = ("<%expressions.new_task_reminder%>") / position = (50%, 80%) / txcolor = <%expressions.newTaskReminderColor%> / size = (80%, 6%) / fontstyle = ("Arial", 3%, false, false, false, false, 5, 1) </text> <expressions> /new_task_reminder={ if(values.targetTask == values.taskA) { "BUCHSTABE ~n '<%text.letter.#ff2e50%>' ~n'<%parameters.leftKeyLabel%>': <%expressions.letter_left%> '<%parameters.rightKeyLabel%>': <%expressions.letter_right%>"; } else if (values.targetTask == values.taskB) { "ZAHL ~n '<%text.number.#ff2e50%>' ~n'<%parameters.leftKeyLabel%>': <%expressions.number_left%> '<%parameters.rightKeyLabel%>': <%expressions.number_right%>"; } else { "?????????"; } } /newTaskReminderColor={ if(values.targetTask == values.taskA) { darkmagenta; } else if (values.targetTask == values.taskB) { limegreen; } else { orangered; } } </expressions>
<text newTaskReminder> / items = ("<%expressions.new_task_reminder%>") / position = (50%, 80%) / txcolor = <%expressions.newTaskReminderColor%> / size = (80%, 6%) / fontstyle = ("Arial", 3%, false, false, false, false, 5, 1) </text>
This is invalid syntax / the /txcolor attribute does not work like that. What you need to do is set the <text> element's textcolor property in your <expressions> directly, as in
<expressions> /newTaskReminderColor = if(values.targetTask == values.taskA) { text.newTaskReminder.textcolor = darkmagenta; } else if (values.targetTask == values.taskB) { text.newTaskReminder.textcolor = limegreen; } else { text.newTaskReminder.textcolor = orangered; } </expressions>
<values> / targetTask = 1 / taskA = 1 / taskB = 2 </values>
<block myblock> / trials = [1=mytrial] </block>
<trial mytrial> / stimulusframes = [1=newTaskReminder] / validresponse = (57) </trial>
<text newTaskReminder> / onprepare = [ expressions.newTaskReminderColor; ] / items = ("Some text....") / position = (50%, 80%) / size = (80%, 6%) / fontstyle = ("Arial", 3%, false, false, false, false, 5, 1) </text>
|
By Lingi - 4/3/2018
This worked as inteded! Thank you very much for your quick and competent help!
|
|