I am have a new issue having just fixed the last one with the help of the Forums.
The new issue is that when dragging text, I get the below error. I have looked on the Forums and it would seem that many people have been having the same issue, however, as far as I can see there has been no solution. I have tried change the units from height to pixels etc… but still nothing.
Oh, it’s probably the same issue actually. This is part of why I suggested just making a TextStim component in the builder, these things are weirdly finicky when you manually define them in code components in PsychoJS (even though it’s usually fine in Python).
So, iteration on the last solution:
score_text = new visual.TextStim(
{"win":psychoJS.window,
"text": 'Score: ${score}',
"pos": [0, 0.4],
"height": 0.05,
"units": "height", //this guy right here
"color": "black"});
When builder-based components are defined at the beginning of the experiment they can actually take "units":undefined and it will be overridden by the window, but I think it doesn’t do that if you manually add a component later in the code. I’m not sure why, that’s definitely a PsychoJS-specific behavior.
Actually, if you’re going to define score_text in a code component, I strongly recommend putting it in the “begin experiment” or “begin routine” code and just leaving the score_text.draw() in the “each frame” code when you want it to appear. Right now you’re re-creating the whole object on every frame, which isn’t ideal.
I cannot seem to get this to work, I get the same error as before. I think I am going to try and workout how to create the text component and do the score that way, like you advised.
At the moment (in builder), the score appears on top of the screen in the centre, and then updates every time someone moves a word in the correct box. What is correct and what is not is already defined within the code component.
Then the issue might be that the units for your other stimuli (which are builder components) are undefined, which is odd. It might have to do with switching the window units back and forth, but you might need to go through each of them and manually set their units to “height”. The bottom line is that the error is coming up because some visual component should have window units and doesn’t, and for some reason it’s not taking the default value from your window settings.
I have created the Text component for the score, this shows up when running the programme, however, the score does not update when the participant scores. I have inputted the code print(score), to ensure that the scoring is still working, and it is. The only thing is that it does not update the score on the screen.
Unfortunately, I have created the text component, and I am still getting the same error when syncing to Pavlovia, ‘Unknown position units: undefined’. Works fine on builder but not on Pavlovia. This issue happens as soon as I click the mouse button.
This is just a cache-clearing issue. If we’re lucky, you should be able to try the expeirment in an incognito tab and it’ll just work.
One of the text elements still doesn’t have defined units. Glancing through the code, this is true of text_4 and welcome_text, though I’m not sure why either of those would cause trouble with the mouse since neither of them are part of the drag-and-drop code.
It’s something about mouse.isPressedIn with TextStim on PsychoJS. This is not impossible, but it would be more annoying to fix. You might need to manually check a location range or radius around the text instead of using IsPressedIn (i.e., basically make your own isPressedIn function). I hope this isn’t the case, but it’s the only other thing I can think of.
So, fingers crossed that it’s (1) or (2), and if not, it’s still fixable, just more effort.
I firstly started off with your first point and got a new error now (may be a good sign) * IndexSizeError: Failed to execute ‘getImageData’ on ‘OffscreenCanvasRenderingContext2D’: The source width is 0.
I opened the Developers tool to understand where the error takes place, and I could not understand ‘PsychoJS.js:873 IndexSizeError: Failed to execute ‘getImageData’ on ‘OffscreenCanvasRenderingContext2D’: The source width is 0.
at TextStim.getTextMetrics (TextStim.js:196:41)
at TextStim._estimateBoundingBox (TextStim.js:330:28)
at new TextStim (TextStim.js:178:8)
at Scheduler.experimentInit [as _currentTask] (Drag and Drop.js:131:18)
at Scheduler._runNextTasks (Scheduler.js:225:24)
at async Scheduler._runNextTasks (Scheduler.js:232:13)
at async update (Scheduler.js:139:18)
window.onunhandledrejection @ PsychoJS.js:873’
If this refers to line 131 then it would be the name: ‘Welcome_text’,
However, I am sure that is incorrect and not what you was after, therefore, I am unsure on what line this is, as I have looked through the Java code and cannot see anything that resembles this.
I deleted the welcome_text and I am now getting the original error. I really appreciate the help, but if this is too complicated to fix, I may attempt to recreate this task in another software. Such as Gorilla.
In fairness I think you’ve discovered a genuine underlying bug that needs to be fixed, and one I’ve never seen before, so it’s a fairly extraordinary occurrence!
I downloaded a copy of your repository and when I have time I’ll mess around with it some more and see what I can figure out. I tried a couple of quick little things and my conclusion so far is that this is definitely a real bug, but a hard one to pin down. It’s something about updating the position of the text objects from the mouse position, but there’s no obvious reason that this should be difficult.