Button not working in preview


#1

Hi, I´ve put a button in a sprite extension, whitout code onRun, but when I click it throw an error in device.id. (Same happens if I put code in onRun function)

Uncaught TypeError: Cannot read properties of undefined (reading ‘id’)
at Object.onRun (interfaz_robotica_1056308.js:1693:89)
at e.buttonCallback [as callback_] (ext-manager.429bdf4c.js:1:44947)
at Blockly.FlyoutButton.onMouseUp_ (315.0d9c5fdb.js:1:867704)
at SVGGElement.s (315.0d9c5fdb.js:1:988253)

image


#2

The extension builder thinks there is an error in your coding (the parts underlined in red and the red “X”). Does it say what it expected? @astoctas


#3

This is the error, it´s not my code, it is builder´s


#4

What it means by “Cannot read properties” is it thinks you have made an error. Maybe it is wrong, maybe it isn’t. What I gather from the error is it thinks that “id” is part of a function (in JavaScript, perhaps?) and that the function has not been defined anywhere.


#5

Try it yourself…in a simple sprite extension, put a button and nothing else. When you click it in preview mode, the error appears. Even if you put any code in onRun, the same error appears.

It´s the same as here: TypeError: Cannot read properties of undefined (reading 'id')


#6

Hmm… I’ll see what I can find out.


#7

@Best_codes Can you find anything out? Regards!


#8

Sorry, I’m very busy. I’ve been trying. Mention @CommandeR @MurrayElliot @Crackel.


#9

I didn’t read all and I don’t have a very high level in this kind of things, but it seems that you are making an extension for sprites, while buttons are made for devices. Because of that, device is undefined, and undefined.id throws the error.


#10

Or thete is another reason, such as no device is connected, etc… I don’t know but it might help