jmoenig / Snap

a visual programming language inspired by Scratch
http://snap.berkeley.edu
GNU Affero General Public License v3.0
1.49k stars 743 forks source link

Scenes menu triggers an exception when in the block editor #3057

Open ToonTalk opened 2 years ago

ToonTalk commented 2 years ago

Of course it works fine outside of the editor. (7.3.1)

blocks.js?version=2022-03-15:10583 Uncaught TypeError: Cannot read properties of null (reading 'scenes') at InputSlotMorph.scenesMenu (blocks.js?version=2022-03-15:10583:47) at InputSlotMorph.menuFromDict (blocks.js?version=2022-03-15:9909:36) at InputSlotMorph.dropDownMenu (blocks.js?version=2022-03-15:9849:21) at InputSlotMorph.mouseClickLeft (blocks.js?version=2022-03-15:10721:14) at HandMorph.processMouseUp (morphic.js?version=2022-01-28:11473:29) at HTMLCanvasElement. (morphic.js?version=2022-01-28:12245:23)

WarpedWartWars commented 2 years ago

I can't seem to reproduce this: Screenshot (72) but I think what's happening is that, in InputSlotMorph.prototype.scenesMenu, this.parentThatIsA(IDE_Morph) is null. I'm not sure why that would be the case, though.

ToonTalk commented 2 years ago

Add the switch to scene to a block you are defining and try again.

WarpedWartWars commented 2 years ago

I see now. Can you rename this to make it clear it's only in the block editor?

And in this case, it makes sense, because block editors aren't children of the IDE. That is, if visible stepping and live coding are both off.

ToonTalk commented 2 years ago

Done. But I find the terminology a bit odd. There is the script area and there is the (script) editor which I see now the manual calls the Block Editor.

brianharvey commented 2 years ago

The script area is where scripts are edited! The only exception is that definitions of blocks are edited in the Block Editor. This is so that, unlike in Scratch, definitions of blocks don't clutter up the script area.

ToonTalk commented 2 years ago

That makes sense. But note that the script area is analogous to a command line (except for hats and their persistence) and the Block Editor is analogous to a program editor.

brianharvey commented 2 years ago

Like most analogies, that one seems to me to cast more shadow than light. Consider that Snap! is multithreaded and event-driven, so the "command line" picture really works only if there's one when-green-flag-clicked script and nothing else. And only one sprite.

As to "a program editor," I think a better analogy is to Logo, which has the EDIT command to edit a procedure and the EDALL command to edit all the procedures at once. But even in EDALL, there's no "program," just procedures. Logo does behave like a command line, though.