psychojs icon indicating copy to clipboard operation
psychojs copied to clipboard

Button: Color not reset on first frame

Open RebeccaHirst opened this issue 3 years ago • 2 comments

If a button is changed in color (e.g. on a click). it is not "reset" on the first frame of the next trial, so it will appear to "flash" as the previously set color.

In this minimal demo the button starts inactive and then becomes active (i.e. clickable) - if you click the active button it will turn red, then you can "submit" your answer". On the next trial the same procedure should happen i.e. the active button is grey when it first becomes active, untill it is clicked. What actually happens is that it is red for the first frame it is presented before quickly returning to grey.

minimal demo here: https://pavlovia.org/Consultancy/buttoncolorchangebug

RebeccaHirst avatar Jul 30 '21 15:07 RebeccaHirst

Thanks for flagging @RebeccaHirst, ButtonStim does no color handling of its own, the fix is probably with the TextBox parent class

thewhodidthis avatar Aug 02 '21 08:08 thewhodidthis

@RebeccaHirst OK this looks like a boilerplate issue. I have created a support fork to illustrate how when thisColor is reset at the beginning of each trial, the colorFill property for each ButtonStim instance is still "red" and to demonstrate the potential workaround of setting fillColor for color_button_2 before the component gains STARTED status rather than on each frame once the STARTED flag is set, which also comes with a slight performance penalty, if that makes any sense!

thewhodidthis avatar Aug 02 '21 17:08 thewhodidthis