-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broadcast Inputs and Implicit Message Deletion #1302
Broadcast Inputs and Implicit Message Deletion #1302
Conversation
No variables in shadows: read this thread. |
@rachel-fenichel, thanks for the pointer to the thread. That makes a lot of sense. I guess this should also factor into the discussion for #1290. If we explicitly disallow deletion/renaming for broadcast messages (not saying this is what will necessarily happen), would this then be a non-issue? e.g. Is deletion/renaming the only consideration we should make when deciding to have a field_variable in a shadow? |
I think deletion/renaming is the only concern, but it includes implicit deletion/renaming. Variable fields may now be better at creating variables at the right time, so maybe it's okay. I would experiment with some of the workflows from that thread to see if anything ends up feeling too weird. |
Right now I have no deletion of broadcast messages implemented at all (explicit or implicit), so testing that out will probably have to wait until we make a decision about what deletion behavior should be. |
f9458a6
to
ef3acb8
Compare
@paulkaplan Does it make sense to change this and corresponding PR's mentioned above to be against develop instead of these new separate branches ('broadcast-messages' branch)? My original intuition for the separate branches was so that they would be a staging area for all of the new broadcast block changes (including merging in Rachel's changes from upstream blockly). I think this might not make sense anymore, since merging in Rachel's work will be a pretty substantial change/refactor anyways, and it's not planned for our current milestone. |
ea81b30
to
43b3e60
Compare
…ble shadows. Flyout stuff needs to be fixed.
…ow follow scratch 2 behavior of displaying the message that comes first in sorted order (same sort as dropdown)
43b3e60
to
8447633
Compare
var broadcastMsgType = Blockly.BROADCAST_MESSAGE_VARIABLE_TYPE; | ||
var broadcastVars = this.sourceBlock_.workspace.getVariablesOfType(broadcastMsgType); | ||
if (this.variableType == broadcastMsgType && broadcastVars.length != 0) { | ||
broadcastVars.sort(Blockly.VariableModel.compareByName); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG
Did you check for problems related to variables in shadows? |
@rachel-fenichel I believe we don't have any issues with variables in shadows right now. Variables in shadows aren't implicitly deleted unless all blocks (including obscured shadows) with a particular variable are deleted. This is not the same behavior as in scratch 2 where a block covering a shadow deletes the underlying variable in the shadow field. We decided to avoid this in Scratch 3 (unless an issue with it comes up) because in Scratch 2, this is how the empty string names are created, and we wanted to avoid those in Scratch 3, if possible. |
Resolves
Resolves #1268
Resolves #1270
Resolves #1290
Resolves #1304
Proposed Changes
Broadcast blocks (namely
broadcast
andbroadcast and wait
) now have pluggable inputs.New messages can once again be created from the flyout (resolving the issue in #1270).
New messages created from a block in the flyout are created as variables in the flyout's target workspace, thus appearing in all broadcast block dropdown menus.
A message is created when either:
New message
option in any of the broadcast block dropdowns.A message is deleted using the implicit deletion behavior from SB2. Most of this functionality is implemented in scratch-vm. A message is deleted (disappears from dropdowns) if all blocks referencing that message are removed from the VM. This deletion behavior updates every time the workspace is updated (e.g. switching sprites or switching between the blocks tab and the costumes/sounds tabs). When the workspace is updated, the broadcast blocks in the flyout update their fields according to SB2 behavior -- the broadcast message that comes first in sorted order will appear selected in the field of each of the broadcast blocks in the flyout. The sorting behavior is the same as that used to sort the options in the dropdown menu (alphanumeric sorting by message name).
The assertion that shadows cannot have variables is no longer true, so the assertion statement has been removed.
Diversions from SB2
SB2 projects that have empty string message names will be converted to a fresh name
message#
.In SB2, plugging in an input, e.g.
((1) + (1))
, into abroadcast [foo]
orbroadcast [foo] and wait
block, and then taking that input back out will result in removing the old message namefoo
and replacing it with the empty string. In the proposed changes,foo
will remain in the message dropdowns, as well as in the shadow behind the plugged in input.The reason for these divergences are to avoid the potential for buggy behavior when introducing this round-about way of creating empty string message names when they are otherwise disallowed from explicit creation.
If we decide that we would like to maintain this SB2 behavior, that change can be made.
Reason for Changes
To maintain compatibility with Scratch 2.0 which allows blocks to be plugged into the broadcast block inputs, and has the implicit deletion behavior.
Test Coverage
Existing tests pass.
Additional Notes
This PR depends on corresponding PRs in scratch-vm and scratch-gui:
LLK/scratch-gui#1033
LLK/scratch-vm#860
These three PRs can be tested together here.