Repository: psychopy/psychopy

Issue:
Keyboard: Correct answer box greyed out and not editable if store correct checked
If the "Store Correct" box in the data tab is checked in a keyboard component the Correct Answer field remains greyed out, so the user cannot enter the correct answer i.e. `$corrAns`


Discussion:
update, if you check the Store Correct box > press OK > reopen the component, the Correct Answer field is *then* editable
I'd wager this is the same validation bug I've just passed to @mdcutone as I couldn't figure it out... It also means that if you add invalid code, the warning message doesn't go away and the Okay button doesn't enable even after you fix the code
The validation bug was affecting this but the crucial thing is that this box had its own special method outside the `depends` system - it doesn't do anything special though, so deprecating the function and using `depends` instead is the way to go. On it now :) 

Resolving patch:
diff --git a/psychopy/app/builder/dialogs/__init__.py b/psychopy/app/builder/dialogs/__init__.py
--- a/psychopy/app/builder/dialogs/__init__.py
+++ b/psychopy/app/builder/dialogs/__init__.py
@@ -1594,13 +1594,6 @@ def __init__(self, frame, element, experiment,
         self.app = frame.app
         self.dpi = self.app.dpi
 
-        # for input devices:
-        if 'storeCorrect' in self.params:
-            # do this just to set the initial values to be
-            self.onStoreCorrectChange(event=None)
-            self.Bind(wx.EVT_CHECKBOX, self.onStoreCorrectChange,
-                      self.paramCtrls['storeCorrect'].valueCtrl)
-
         # for all components
         self.show(testing)
         if not testing:
@@ -1608,18 +1601,6 @@ def __init__(self, frame, element, experiment,
                 self.params = self.getParams()  # get new vals from dlg
             self.Destroy()
 
-    def onStoreCorrectChange(self, event=None):
-        """store correct has been checked/unchecked. Show or hide the
-        correctAns field accordingly
-        """
-        if self.paramCtrls['storeCorrect'].valueCtrl.GetValue():
-            self.paramCtrls['correctAns'].valueCtrl.Enable()
-        else:
-            self.paramCtrls['correctAns'].valueCtrl.Disable()
-        self.mainSizer.Layout()
-        self.Fit()
-        self.Refresh()
-
 
 class DlgExperimentProperties(_BaseParamsDlg):
 
diff --git a/psychopy/experiment/components/keyboard/__init__.py b/psychopy/experiment/components/keyboard/__init__.py
--- a/psychopy/experiment/components/keyboard/__init__.py
+++ b/psychopy/experiment/components/keyboard/__init__.py
@@ -114,6 +114,15 @@ def __init__(self, exp, parentName, name='key_resp',
             hint=msg,
             label=_localized['storeCorrect'])
 
+        self.depends += [  # allows params to turn each other off/on
+            {"dependsOn": "storeCorrect",  # must be param name
+             "condition": "== True",  # val to check for
+             "param": "correctAns",  # param property to alter
+             "true": "enable",  # what to do with param if condition is True
+             "false": "disable",  # permitted: hide, show, enable, disable
+             }
+        ]
+
         msg = _translate(
             "What is the 'correct' key? Might be helpful to add a "
             "correctAns column and use $correctAns to compare to the key "


Test patch: