From cc01fe3c397ce9fc74c42bcb44836e0f2ce026b0 Mon Sep 17 00:00:00 2001 From: Todd Parsons Date: Fri, 4 Nov 2022 13:55:03 +0000 Subject: [PATCH] Add `reset` method to ButtonStim to match Python --- src/visual/ButtonStim.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/visual/ButtonStim.js b/src/visual/ButtonStim.js index 604983c4..8adc1aea 100644 --- a/src/visual/ButtonStim.js +++ b/src/visual/ButtonStim.js @@ -136,4 +136,18 @@ export class ButtonStim extends TextBox { return this.listener.isPressedIn(this, [1, 0, 0]); } + + /** + * Clear previously stored times on / off and check current click state. + * + * In Builder, this is called at the start of each routine. + */ + reset() { + + // Update wasClicked (so continued clicks at routine start are considered) + this.wasClicked = this.isClicked + // Clear on/off times + this.timesOn = [] + this.timesOff = [] + } }