Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
BF: Replace 'use prefs' default with 'height' for JS window units
'use preferences' for window units breaks JS code. This fix sets the default window units as 'height'. Fixes new issue in #2227.
  • Loading branch information
dvbridges authored and peircej committed Jan 31, 2019
1 parent aa14f1b commit a686dbf
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions psychopy/experiment/components/settings/__init__.py
Expand Up @@ -723,17 +723,25 @@ def writeWindowCode(self, buff):
buff.writeIndentedLines(code)

def writeWindowCodeJS(self, buff):
"""Setup the JS window code.
"""
# Replace instances of 'use prefs'
units = self.params['Units'].val
if units == 'use prefs':
units = 'height'

code = ("// init psychoJS:\n"
"var psychoJS = new PsychoJS({{\n"
" debug: true\n"
"}});\n\n"
"// open window:\n"
"psychoJS.openWindow({{\n"
" fullscr: {fullScr},\n"
" color: new util.Color({params[color]}),\n"
" units: {params[Units]}\n"
"}});\n").format(fullScr=str(self.params['Full-screen window']).lower(),
params=self.params)
"var psychoJS = new PsychoJS({{\n"
" debug: true\n"
"}});\n\n"
"// open window:\n"
"psychoJS.openWindow({{\n"
" fullscr: {fullScr},\n"
" color: new util.Color({params[color]}),\n"
" units: '{units}'\n"
"}});\n").format(fullScr=str(self.params['Full-screen window']).lower(),
params=self.params,
units=units)
buff.writeIndentedLines(code)

def writeEndCode(self, buff):
Expand Down

0 comments on commit a686dbf

Please sign in to comment.